Esempio n. 1
0
 public TimeBucket <TCalendar> AddDatePart(int value)
 {
     Given = StartPoint = DatePart switch
     {
         DatePart.Minute => StartPoint.AddMinutes(value),
         DatePart.Hour => StartPoint.AddHours(value),
         DatePart.Day => StartPoint.AddDays(value),
         DatePart.Week => StartPoint.AddDays(7 * value),
         DatePart.Month => _calendar.AddMonths(StartPoint, value),
         DatePart.Year => _calendar.AddYears(StartPoint, 1),
         _ => throw new ArgumentOutOfRangeException(nameof(Contract.DatePart), DatePart, null)
     };
     EndPoint = DatePart switch
     {
         DatePart.Minute => EndPoint.AddMinutes(value),
         DatePart.Hour => EndPoint.AddHours(value),
         DatePart.Day => EndPoint.AddDays(value),
         DatePart.Week => EndPoint.AddDays(7 * value),
         DatePart.Month => _calendar.AddMonths(EndPoint, value),
         DatePart.Year => _calendar.AddYears(EndPoint, 1),
         _ => throw new ArgumentOutOfRangeException(nameof(Contract.DatePart), DatePart, null)
     };
     PartialStart = PartialEnd = false;
     return(this);
 }