public void testCalendar()
throws Exception
{
Calendar cal = getStartCalendar();
PGInterval pgi = new PGInterval("@ 1 year 1 mon 1 day 1 hour 1 minute 1 secs");
pgi.add(cal);
assertEquals(2006, cal.get(Calendar.YEAR));
assertEquals(5, cal.get(Calendar.MONTH));
assertEquals(30, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(16, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(36, cal.get(Calendar.MINUTE));
assertEquals(43, cal.get(Calendar.SECOND));
assertEquals(100, cal.get(Calendar.MILLISECOND));
pgi = new PGInterval("@ 1 year 1 mon 1 day 1 hour 1 minute 1 secs ago");
pgi.add(cal);
assertEquals(2005, cal.get(Calendar.YEAR));
assertEquals(4, cal.get(Calendar.MONTH));
assertEquals(29, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(35, cal.get(Calendar.MINUTE));
assertEquals(42, cal.get(Calendar.SECOND));
assertEquals(100, cal.get(Calendar.MILLISECOND));
cal = getStartCalendar();
pgi = new PGInterval("@ 1 year -23 hours -3 mins -3.30 secs");
pgi.add(cal);
assertEquals(2006, cal.get(Calendar.YEAR));
assertEquals(4, cal.get(Calendar.MONTH));
assertEquals(28, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(16, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(32, cal.get(Calendar.MINUTE));
assertEquals(38, cal.get(Calendar.SECOND));
assertEquals(800, cal.get(Calendar.MILLISECOND));
pgi = new PGInterval("@ 1 year -23 hours -3 mins -3.30 secs ago");
pgi.add(cal);
assertEquals(2005, cal.get(Calendar.YEAR));
assertEquals(4, cal.get(Calendar.MONTH));
assertEquals(29, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));