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

View File

@@ -4,7 +4,7 @@ namespace Dlhis.Canteen.Order;
/// <summary>
/// 临时的扩展类 todo: 嵌入框架
/// 临时的扩展类 todo: 嵌入框架
/// </summary>
public static class TimePeriodExtensions
{
@@ -15,19 +15,16 @@ public static class TimePeriodExtensions
if (period.IsCrossDay())
{
var currentStart = DateTime.Today.Add(period.Start.Value.ToTimeSpan());
var endOfDay = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
if (dateTime >= currentStart && dateTime <= endOfDay)
//第二天
if (dateTime.Hour >= 0)
{
start = DateTime.Today.Add(period.Start.Value.ToTimeSpan());
end = DateTime.Today.AddDays(1).Add(period.End.Value.ToTimeSpan());
start = DateTime.Today.AddDays(-1).Add(period.Start.Value.ToTimeSpan());
end = DateTime.Today.Add(period.End.Value.ToTimeSpan());
}
else
{
//第二天
start = DateTime.Today.AddDays(-1).Add(period.Start.Value.ToTimeSpan());
end = DateTime.Today.Add(period.End.Value.ToTimeSpan());
start = DateTime.Today.Add(period.Start.Value.ToTimeSpan());
end = DateTime.Today.AddDays(1).Add(period.End.Value.ToTimeSpan());
}
}
else