fix 修改区间判断

This commit is contained in:
2024-01-18 18:24:02 +08:00
parent fd7034ad49
commit e7b74ff2b3

View File

@@ -15,17 +15,20 @@ public static class TimePeriodExtensions
if (period.IsCrossDay()) if (period.IsCrossDay())
{ {
//第二天 var currentStart = DateTime.Today.Add(period.Start.Value.ToTimeSpan());
if (dateTime.Hour >= 0) var endOfDay = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
{
start = DateTime.Today.AddDays(-1).Add(period.Start.Value.ToTimeSpan()); if (dateTime >= currentStart && dateTime <= endOfDay)
end = DateTime.Today.Add(period.End.Value.ToTimeSpan());
}
else
{ {
start = DateTime.Today.Add(period.Start.Value.ToTimeSpan()); start = DateTime.Today.Add(period.Start.Value.ToTimeSpan());
end = DateTime.Today.AddDays(1).Add(period.End.Value.ToTimeSpan()); end = DateTime.Today.AddDays(1).Add(period.End.Value.ToTimeSpan());
} }
else
{
//第二天
start = DateTime.Today.AddDays(-1).Add(period.Start.Value.ToTimeSpan());
end = DateTime.Today.Add(period.End.Value.ToTimeSpan());
}
} }
else else
{ {