public void testSampleDate1() { DateTime dt = new DateTime(1945, 11, 12, 0, 0, 0, 0, ISO_UTC); dt = dt.withChronology(ISLAMIC_UTC); assertEquals(IslamicChronology.AH, dt.getEra()); assertEquals(14, dt.getCenturyOfEra()); // TODO confirm assertEquals(64, dt.getYearOfCentury()); assertEquals(1364, dt.getYearOfEra()); assertEquals(1364, dt.getYear()); Property fld = dt.year(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(new DateTime(1365, 12, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1)); assertEquals(12, dt.getMonthOfYear()); fld = dt.monthOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(12, fld.getMaximumValue()); assertEquals(12, fld.getMaximumValueOverall()); assertEquals(new DateTime(1365, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1)); assertEquals(new DateTime(1364, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addWrapFieldToCopy(1)); assertEquals(6, dt.getDayOfMonth()); fld = dt.dayOfMonth(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(29, fld.getMaximumValue()); assertEquals(30, fld.getMaximumValueOverall()); assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1)); assertEquals(DateTimeConstants.MONDAY, dt.getDayOfWeek()); fld = dt.dayOfWeek(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(7, fld.getMaximumValue()); assertEquals(7, fld.getMaximumValueOverall()); assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1)); assertEquals(6 * 30 + 5 * 29 + 6, dt.getDayOfYear()); fld = dt.dayOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(354, fld.getMaximumValue()); assertEquals(355, fld.getMaximumValueOverall()); assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1)); assertEquals(0, dt.getHourOfDay()); assertEquals(0, dt.getMinuteOfHour()); assertEquals(0, dt.getSecondOfMinute()); assertEquals(0, dt.getMillisOfSecond()); }
public void testSampleDate2() { DateTime dt = new DateTime(2005, 11, 26, 0, 0, 0, 0, ISO_UTC); dt = dt.withChronology(ISLAMIC_UTC); assertEquals(IslamicChronology.AH, dt.getEra()); assertEquals(15, dt.getCenturyOfEra()); // TODO confirm assertEquals(26, dt.getYearOfCentury()); assertEquals(1426, dt.getYearOfEra()); assertEquals(1426, dt.getYear()); Property fld = dt.year(); assertEquals(true, fld.isLeap()); assertEquals(1, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(10, dt.getMonthOfYear()); fld = dt.monthOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(12, fld.getMaximumValue()); assertEquals(12, fld.getMaximumValueOverall()); assertEquals(24, dt.getDayOfMonth()); fld = dt.dayOfMonth(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(29, fld.getMaximumValue()); assertEquals(30, fld.getMaximumValueOverall()); assertEquals(DateTimeConstants.SATURDAY, dt.getDayOfWeek()); fld = dt.dayOfWeek(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(7, fld.getMaximumValue()); assertEquals(7, fld.getMaximumValueOverall()); assertEquals(5 * 30 + 4 * 29 + 24, dt.getDayOfYear()); fld = dt.dayOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(355, fld.getMaximumValue()); assertEquals(355, fld.getMaximumValueOverall()); assertEquals(0, dt.getHourOfDay()); assertEquals(0, dt.getMinuteOfHour()); assertEquals(0, dt.getSecondOfMinute()); assertEquals(0, dt.getMillisOfSecond()); }
public void testSampleDate3() { DateTime dt = new DateTime(1426, 12, 24, 0, 0, 0, 0, ISLAMIC_UTC); assertEquals(IslamicChronology.AH, dt.getEra()); assertEquals(1426, dt.getYear()); Property fld = dt.year(); assertEquals(true, fld.isLeap()); assertEquals(1, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(12, dt.getMonthOfYear()); fld = dt.monthOfYear(); assertEquals(true, fld.isLeap()); assertEquals(1, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(12, fld.getMaximumValue()); assertEquals(12, fld.getMaximumValueOverall()); assertEquals(24, dt.getDayOfMonth()); fld = dt.dayOfMonth(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(30, fld.getMaximumValue()); assertEquals(30, fld.getMaximumValueOverall()); assertEquals(DateTimeConstants.TUESDAY, dt.getDayOfWeek()); fld = dt.dayOfWeek(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(7, fld.getMaximumValue()); assertEquals(7, fld.getMaximumValueOverall()); assertEquals(6 * 30 + 5 * 29 + 24, dt.getDayOfYear()); fld = dt.dayOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(355, fld.getMaximumValue()); assertEquals(355, fld.getMaximumValueOverall()); assertEquals(0, dt.getHourOfDay()); assertEquals(0, dt.getMinuteOfHour()); assertEquals(0, dt.getSecondOfMinute()); assertEquals(0, dt.getMillisOfSecond()); }
public void testSampleDate() { DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(COPTIC_UTC); assertEquals(CopticChronology.AM, dt.getEra()); assertEquals(18, dt.getCenturyOfEra()); // TODO confirm assertEquals(20, dt.getYearOfCentury()); assertEquals(1720, dt.getYearOfEra()); assertEquals(1720, dt.getYear()); Property fld = dt.year(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(new DateTime(1721, 10, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1)); assertEquals(10, dt.getMonthOfYear()); fld = dt.monthOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(13, fld.getMaximumValue()); assertEquals(13, fld.getMaximumValueOverall()); assertEquals(new DateTime(1721, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(4)); assertEquals(new DateTime(1720, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addWrapFieldToCopy(4)); assertEquals(2, dt.getDayOfMonth()); fld = dt.dayOfMonth(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(30, fld.getMaximumValue()); assertEquals(30, fld.getMaximumValueOverall()); assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1)); assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek()); fld = dt.dayOfWeek(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(7, fld.getMaximumValue()); assertEquals(7, fld.getMaximumValueOverall()); assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1)); assertEquals(9 * 30 + 2, dt.getDayOfYear()); fld = dt.dayOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(365, fld.getMaximumValue()); assertEquals(366, fld.getMaximumValueOverall()); assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1)); assertEquals(0, dt.getHourOfDay()); assertEquals(0, dt.getMinuteOfHour()); assertEquals(0, dt.getSecondOfMinute()); assertEquals(0, dt.getMillisOfSecond()); }
public void testSampleDate() { DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(ETHIOPIC_UTC); assertEquals(EthiopicChronology.EE, dt.getEra()); assertEquals(20, dt.getCenturyOfEra()); // TODO confirm assertEquals(96, dt.getYearOfCentury()); assertEquals(1996, dt.getYearOfEra()); assertEquals(1996, dt.getYear()); Property fld = dt.year(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(new DateTime(1997, 10, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1)); assertEquals(10, dt.getMonthOfYear()); fld = dt.monthOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(13, fld.getMaximumValue()); assertEquals(13, fld.getMaximumValueOverall()); assertEquals(new DateTime(1997, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(4)); assertEquals(new DateTime(1996, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addWrapFieldToCopy(4)); assertEquals(2, dt.getDayOfMonth()); fld = dt.dayOfMonth(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(30, fld.getMaximumValue()); assertEquals(30, fld.getMaximumValueOverall()); assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1)); assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek()); fld = dt.dayOfWeek(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(7, fld.getMaximumValue()); assertEquals(7, fld.getMaximumValueOverall()); assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1)); assertEquals(9 * 30 + 2, dt.getDayOfYear()); fld = dt.dayOfYear(); assertEquals(false, fld.isLeap()); assertEquals(0, fld.getLeapAmount()); assertEquals(null, fld.getLeapDurationField()); assertEquals(1, fld.getMinimumValue()); assertEquals(1, fld.getMinimumValueOverall()); assertEquals(365, fld.getMaximumValue()); assertEquals(366, fld.getMaximumValueOverall()); assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1)); assertEquals(0, dt.getHourOfDay()); assertEquals(0, dt.getMinuteOfHour()); assertEquals(0, dt.getSecondOfMinute()); assertEquals(0, dt.getMillisOfSecond()); }