fix 修改区间判断

This commit is contained in:
2024-01-18 18:24:02 +08:00
committed by cheche
parent bf64647d71
commit be2552be32

View File

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