예제 #1
0
        private static bool InDayOfMonthRange(IrIntegerRange range, int year, int month, int dayOfMonth)
        {
            if (range.Start < 0 || (range.IsRange && range.End < 0))
            {
                // one of the range values is negative, so we need to convert it to a positive by counting back from the end of the month
                var daysInMonth = DateTime.DaysInMonth(year, month);
                range = range.CloneWithRevisedRange(
                    range.Start < 0 ? daysInMonth + range.Start + 1 : range.Start,
                    range.End < 0 ? daysInMonth + range.End + 1 : range.End
                );
            }

            return InIntegerRange(range, dayOfMonth, DaysInPreviousMonth(year, month), 1);
        }
예제 #2
0
 private static bool InDayOfYearRange(IrIntegerRange range, int year, int month, int dayOfYear)
 {
     if (range.Start < 0 || (range.IsRange && range.End < 0))
     {
         // one of the range values is negative, so we need to convert it to a positive
         var daysInYear = DateTime.IsLeapYear(year) ? 366 : 365;
         range = range.CloneWithRevisedRange(
             range.Start < 0 ? daysInYear + range.Start + 1 : range.Start,
             range.End < 0 ? daysInYear + range.End + 1 : range.End
         );
     }
     var daysInPrevYear = DateTime.IsLeapYear(year-1) ? 366 : 365;
     return InIntegerRange(range, dayOfYear, daysInPrevYear);
 }