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);
}
}