using Kurisu.Core.CustomClass; namespace Dlhis.Canteen.Order; /// /// 临时的扩展类 todo: 嵌入框架 /// public static class TimePeriodExtensions { public static bool IsPresent1(this TimePeriod period, DateTime dateTime) { DateTime start; DateTime end; 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) { 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 { start = DateTime.Today.Add(period.Start.Value.ToTimeSpan()); end = DateTime.Today.Add(period.End.Value.ToTimeSpan()); } return dateTime >= start && dateTime <= end; } }