This commit is contained in:
cheche
2024-01-18 18:27:31 +08:00
parent e7b74ff2b3
commit bf64647d71

View File

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