// the second Monday, April 10 at 12 noon, ending the second
// Sunday, September 10, 12 noon in daylight savings, 1 hour
// shift.
// All three should represent the same period
SimpleTimeZone tz =
new SimpleTimeZone(rawOff, "Z1",
Calendar.APRIL, 10, 0, 43200000,
Calendar.SEPTEMBER, 10, 0, 43200000,
dstOff);
int off;
// Test 1/2 hour before dst
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 10, Calendar.SATURDAY, 41400000);
harness.check(off, rawOff); // check 1
// Test 1/2 hour into dst
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 10, Calendar.SATURDAY, 45000000);
harness.check(off, rawOff + dstOff); // check 2
// Test end rule
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 41400000 - dstOff);
harness.check(off, rawOff + dstOff); // check 3
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 45000000 - dstOff);
harness.check(off, rawOff); // check 4
// Test that Nth dayofweek works with day of month rules
tz.setStartRule(Calendar.APRIL, 2, Calendar.SATURDAY, 43200000);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 10, Calendar.SATURDAY, 41400000);
harness.check(off, rawOff); // check 5
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 10, Calendar.SATURDAY, 45000000);
harness.check(off, rawOff + dstOff); // check 6
tz.setEndRule(Calendar.SEPTEMBER, 2, Calendar.FRIDAY, 43200000);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 41400000 - dstOff);
harness.check(off, rawOff + dstOff); // check 7
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 45000000 - dstOff);
harness.check(off, rawOff); // check 8
// Test that -Nth dayofweek works with day of month rules
tz.setStartRule(Calendar.APRIL, -3, Calendar.SATURDAY, 43200000);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 10, Calendar.SATURDAY, 41400000);
harness.check(off, rawOff); // check 9
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 10, Calendar.SATURDAY, 45000000);
harness.check(off, rawOff + dstOff); // check 10
tz.setEndRule(Calendar.SEPTEMBER, -3, Calendar.FRIDAY, 43200000);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 41400000 - dstOff);
harness.check(off, rawOff + dstOff); // check 11
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 45000000 - dstOff);
harness.check(off, rawOff); // check 12
// Friday on or before April 5, 2004 is April 2
// Test arguments get overidden and perform correctly
tz.setStartRule(Calendar.APRIL, 5, Calendar.FRIDAY, 43200000, false);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 2, Calendar.FRIDAY, 41400000);
harness.check(off, rawOff); // check 13
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 2, Calendar.FRIDAY, 45000000);
harness.check(off, rawOff + dstOff); // check 14
tz.setEndRule(Calendar.SEPTEMBER, -15, -Calendar.FRIDAY, 43200000);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 41400000 - dstOff);
harness.check(off, rawOff + dstOff); // check 15
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 45000000 - dstOff);
harness.check(off, rawOff); // check 16
// Sunday on or after April 5, 2004 is April 11
// Test arguments get overidden and perform correctly
tz.setStartRule(Calendar.APRIL, 5, Calendar.SUNDAY, 43200000, true);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 11, Calendar.SUNDAY, 41400000);
harness.check(off, rawOff); // check 17
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 11, Calendar.SUNDAY, 45000000);
harness.check(off, rawOff + dstOff); // check 18
tz.setEndRule(Calendar.SEPTEMBER, 6, -Calendar.FRIDAY, 43200000);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 41400000 - dstOff);
harness.check(off, rawOff + dstOff); // check 19
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.SEPTEMBER, 10, Calendar.FRIDAY, 45000000 - dstOff);
harness.check(off, rawOff); // check 20
// Currently broken in GCJ
tz.setEndRule(Calendar.SEPTEMBER, -6, -Calendar.TUESDAY, 43200000);
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.AUGUST, 31, Calendar.TUESDAY, 41400000 - dstOff);
harness.check(off, rawOff + dstOff); // check 21
off = tz.getOffset(GregorianCalendar.AD, 2004, Calendar.AUGUST, 31, Calendar.TUESDAY, 45000000 - dstOff);
harness.check(off, rawOff); // check 22
// This looks like a Date or DateFormat test, but is here because there was a bug in SimpleTimeZone
// PR libgcj/8321
Date date = new Date(1034705556525l);