Fan.Sys.TimeZone.compareOnDay C# (CSharp) Méthode

compareOnDay() static private méthode

Compare on day. 'd' 5 the fifth of the month 'l' lastSun the last Sunday in the month 'l' lastMon the last Monday in the month '>' Sun>=8 first Sunday on or after the eighth '<' Sun<=25 last Sunday on or before the 25th (not used)
static private compareOnDay ( Rule rule, DstTime x, int year, int mon, int day ) : int
rule Rule
x DstTime
year int
mon int
day int
Résultat int
        static int compareOnDay(Rule rule, DstTime x, int year, int mon, int day)
        {
            // universal atTime might push us into the previous day
              if (x.atMode == 'u' && rule.offset + x.atTime < 0)
            ++day;

              switch (x.onMode)
              {
            case (byte)'d':
              if (x.onDay < day) return -1;
              if (x.onDay > day) return +1;
              return 0;

            case (byte)'l':
              int last = DateTime.weekdayInMonth(year, mon, x.onWeekday, -1);
              if (last < day) return -1;
              if (last > day) return +1;
              return 0;

            case (byte)'>':
              int start = DateTime.weekdayInMonth(year, mon, x.onWeekday, 1);
              while (start < x.onDay) start += 7;
              if (start < day) return -1;
              if (start > day) return +1;
              return 0;

            default:
              throw new Exception(""+(char)x.onMode);
              }
        }