use of android.icu.util.EthiopicCalendar in project j2objc by google.
the class EthiopicTest method TestEraStart.
// basic check to see that we print out eras ok
// eventually should modify to use locale strings and formatter appropriate to coptic calendar
@Test
public void TestEraStart() {
SimpleDateFormat fmt = new SimpleDateFormat("EEE MMM dd, yyyy GG");
fmt.setCalendar(new EthiopicCalendar());
EthiopicCalendar cal = new EthiopicCalendar(1, 0, 1);
assertEquals("Ethiopic Date", "Wed Jan 01, 0001 AD", fmt.format(cal));
cal.set(Calendar.ERA, 0);
cal.set(Calendar.YEAR, 5500);
assertEquals("Ethiopic Date", "Tue Jan 01, 5500 BC", fmt.format(cal));
// The gregorian calendar gets off by two days when
// the date gets low, unless the gregorian changeover is set to
// very early. The funny thing is, it's ok for dates in the year
// 283, but not in the year 7, and it claims to be ok until the year 4.
// should track down when the dates start to differ...
GregorianCalendar gc = new GregorianCalendar();
// act like proleptic Gregorian
gc.setGregorianChange(new Date(Long.MIN_VALUE));
gc.setTime(cal.getTime());
fmt.setCalendar(new GregorianCalendar());
assertEquals("Gregorian Date", "Tue Aug 28, 0007 AD", fmt.format(gc));
}
use of android.icu.util.EthiopicCalendar in project j2objc by google.
the class EthiopicTest method TestCases.
/* DY[20050507] I don't know what this is for yet:
@Test
public void TestRoll() {
int[][] tests = new int[][] {
// input roll by output
// year month day field amount year month day
{ 0001, QIDAH, 2, MONTH, 1, 0001, HIJJAH, 2 }, // non-leap years
{ 0001, QIDAH, 2, MONTH, 2, 0001, MUHARRAM, 2 },
{ 0001, QIDAH, 2, MONTH, -1, 0001, SHAWWAL, 2 },
{ 0001, MUHARRAM, 2, MONTH, 12, 0001, MUHARRAM, 2 },
{ 0001, MUHARRAM, 2, MONTH, 13, 0001, SAFAR, 2 },
{ 0001, HIJJAH, 1, DATE, 30, 0001, HIJJAH, 2 }, // 29-day month
{ 0002, HIJJAH, 1, DATE, 31, 0002, HIJJAH, 2 }, // 30-day month
// Try some rolls that require other fields to be adjusted
{ 0001, MUHARRAM, 30, MONTH, 1, 0001, SAFAR, 29 },
{ 0002, HIJJAH, 30, YEAR, -1, 0001, HIJJAH, 29 },
};
EthiopicCalendar cal = newCivil();
doRollAdd(ROLL, cal, tests);
}
*/
/* Test dates from:
* "The Amharic Letters of Emperor Theodore of Ethiopia to Queen Victoria and
* Her Special Envoy", David Appleyard, Girma Selasse Asfaw, Oxford University Press,
* June 1 1979, ISBN: 0856726605, Longwood Pr Ltd
*
* Ethiopic Gregorian JD
* 20/02/1855 29/10/1862 2401443
* 29/10/1857 05/07/1865 2402423
* 22/05/1858 29/01/1866 2402631
* 10/08/1858 17/04/1866 2402709
* 28/04/1859 05/01/1867 2402972
* 05/05/1860 13/01/1868 2403345
*
* --------------------------------------------------
*
* From the Calendrica applet: http://emr.cs.iit.edu/home/reingold/calendar-book/Calendrica.html
*
* Ethiopic Gregorian JD
* 07/05/-8 01/01/0000 1721060
* 08/05/-7 01/01/0001 1721426
* 06/13/-1 27/08/0007 1723855
*
* 01/01/0000 28/08/0007 1723856
* 01/01/0001 27/08/0008 1724221
* 01/01/0002 27/08/0009 1724586
* 01/01/0003 27/08/0010 1724951
* 01/01/0004 28/08/0011 1724537
* 05/13/0000 26/08/0008 1724220
* 05/13/0001 26/08/0009 1724585
* 05/13/0002 26/08/0010 1724950
* 05/13/0003 26/08/0011 1725315
* 06/13/0003 27/08/0011 1725316 first ethiopian leap year
* 05/13/0004 26/08/0012 1725561
*
* 06/02/1575 13/10/1582 2299159
* 07/02/1575 14/10/1582 2299160 Julian 04/10/1582
* 08/02/1575 15/10/1582 2299161
* 09/02/1575 16/10/1582 2299162
*
* 23/04/1892 01/01/1900 2415021
* 23/04/1997 01/01/2005 2453372
* 05/13/2000 10/09/2008 2454720
*/
/**
* A huge list of test cases to make sure that computeTime and computeFields
* work properly for a wide range of data in the civil calendar.
*/
@Test
public void TestCases() {
final TestCase[] tests = { // Gregorian: 29/10/1862
new TestCase(2401442.5, 1, 1855, 2, 20, WED, 0, 0, 0), // Gregorian: 05/07/1865
new TestCase(2402422.5, 1, 1857, 10, 29, WED, 0, 0, 0), // Gregorian: 29/01/1866
new TestCase(2402630.5, 1, 1858, 5, 22, MON, 0, 0, 0), // Gregorian: 17/04/1866
new TestCase(2402708.5, 1, 1858, 8, 10, TUE, 0, 0, 0), // Gregorian: 05/01/1867
new TestCase(2402971.5, 1, 1859, 4, 28, SAT, 0, 0, 0), // Gregorian: 13/01/1868
new TestCase(2403344.5, 1, 1860, 5, 5, MON, 0, 0, 0), // Gregorian: 01/01/0000
new TestCase(1721059.5, 0, 5492, 5, 7, SAT, 0, 0, 0), // Gregorian: 01/01/0001
new TestCase(1721425.5, 0, 5493, 5, 8, MON, 0, 0, 0), // Gregorian: 27/08/0007
new TestCase(1723854.5, 0, 5499, 13, 6, MON, 0, 0, 0), // Gregorian: 28/08/0007
new TestCase(1723855.5, 0, 5500, 1, 1, TUE, 0, 0, 0), // Gregorian: 27/08/0008
new TestCase(1724220.5, 1, 1, 1, 1, WED, 0, 0, 0), // Gregorian: 27/08/0009
new TestCase(1724585.5, 1, 2, 1, 1, THU, 0, 0, 0), // Gregorian: 27/08/0010
new TestCase(1724950.5, 1, 3, 1, 1, FRI, 0, 0, 0), // Gregorian: 28/08/0011 - dlf
new TestCase(1725316.5, 1, 4, 1, 1, SUN, 0, 0, 0), // Gregorian: 26/08/0008
new TestCase(1724219.5, 0, 5500, 13, 5, TUE, 0, 0, 0), // Gregorian: 26/08/0009
new TestCase(1724584.5, 1, 1, 13, 5, WED, 0, 0, 0), // Gregorian: 26/08/0010
new TestCase(1724949.5, 1, 2, 13, 5, THU, 0, 0, 0), // Gregorian: 26/08/0011
new TestCase(1725314.5, 1, 3, 13, 5, FRI, 0, 0, 0), // Gregorian: 27/08/0011 - first ethiopic leap year
new TestCase(1725315.5, 1, 3, 13, 6, SAT, 0, 0, 0), // Gregorian: 26/08/0012
new TestCase(1725680.5, 1, 4, 13, 5, SUN, 0, 0, 0), // Gregorian: 13/10/1582
new TestCase(2299158.5, 1, 1575, 2, 6, WED, 0, 0, 0), // Gregorian: 14/10/1582 Julian 04/10/1582
new TestCase(2299159.5, 1, 1575, 2, 7, THU, 0, 0, 0), // Gregorian: 15/10/1582
new TestCase(2299160.5, 1, 1575, 2, 8, FRI, 0, 0, 0), // Gregorian: 16/10/1582
new TestCase(2299161.5, 1, 1575, 2, 9, SAT, 0, 0, 0), // Gregorian: 01/01/1900
new TestCase(2415020.5, 1, 1892, 4, 23, MON, 0, 0, 0), // Gregorian: 01/01/2005
new TestCase(2453371.5, 1, 1997, 4, 23, SAT, 0, 0, 0), // Gregorian: 10/09/2008
new TestCase(2454719.5, 1, 2000, 13, 5, WED, 0, 0, 0) };
final TestCase[] testsAmeteAlem = { // Gregorian: 29/10/1862
new TestCase(2401442.5, 0, 7355, 2, 20, WED, 0, 0, 0), // Gregorian: 05/07/1865
new TestCase(2402422.5, 0, 7357, 10, 29, WED, 0, 0, 0), // Gregorian: 29/01/1866
new TestCase(2402630.5, 0, 7358, 5, 22, MON, 0, 0, 0), // Gregorian: 17/04/1866
new TestCase(2402708.5, 0, 7358, 8, 10, TUE, 0, 0, 0), // Gregorian: 05/01/1867
new TestCase(2402971.5, 0, 7359, 4, 28, SAT, 0, 0, 0), // Gregorian: 13/01/1868
new TestCase(2403344.5, 0, 7360, 5, 5, MON, 0, 0, 0), // Gregorian: 01/01/0000
new TestCase(1721059.5, 0, 5492, 5, 7, SAT, 0, 0, 0), // Gregorian: 01/01/0001
new TestCase(1721425.5, 0, 5493, 5, 8, MON, 0, 0, 0), // Gregorian: 27/08/0007
new TestCase(1723854.5, 0, 5499, 13, 6, MON, 0, 0, 0), // Gregorian: 28/08/0007
new TestCase(1723855.5, 0, 5500, 1, 1, TUE, 0, 0, 0), // Gregorian: 27/08/0008
new TestCase(1724220.5, 0, 5501, 1, 1, WED, 0, 0, 0), // Gregorian: 27/08/0009
new TestCase(1724585.5, 0, 5502, 1, 1, THU, 0, 0, 0), // Gregorian: 27/08/0010
new TestCase(1724950.5, 0, 5503, 1, 1, FRI, 0, 0, 0), // Gregorian: 28/08/0011 - dlf
new TestCase(1725316.5, 0, 5504, 1, 1, SUN, 0, 0, 0), // Gregorian: 26/08/0008
new TestCase(1724219.5, 0, 5500, 13, 5, TUE, 0, 0, 0), // Gregorian: 26/08/0009
new TestCase(1724584.5, 0, 5501, 13, 5, WED, 0, 0, 0), // Gregorian: 26/08/0010
new TestCase(1724949.5, 0, 5502, 13, 5, THU, 0, 0, 0), // Gregorian: 26/08/0011
new TestCase(1725314.5, 0, 5503, 13, 5, FRI, 0, 0, 0), // Gregorian: 27/08/0011 - first ethiopic leap year
new TestCase(1725315.5, 0, 5503, 13, 6, SAT, 0, 0, 0), // Gregorian: 26/08/0012
new TestCase(1725680.5, 0, 5504, 13, 5, SUN, 0, 0, 0), // Gregorian: 13/10/1582
new TestCase(2299158.5, 0, 7075, 2, 6, WED, 0, 0, 0), // Gregorian: 14/10/1582 Julian 04/10/1582
new TestCase(2299159.5, 0, 7075, 2, 7, THU, 0, 0, 0), // Gregorian: 15/10/1582
new TestCase(2299160.5, 0, 7075, 2, 8, FRI, 0, 0, 0), // Gregorian: 16/10/1582
new TestCase(2299161.5, 0, 7075, 2, 9, SAT, 0, 0, 0), // Gregorian: 01/01/1900
new TestCase(2415020.5, 0, 7392, 4, 23, MON, 0, 0, 0), // Gregorian: 01/01/2005
new TestCase(2453371.5, 0, 7497, 4, 23, SAT, 0, 0, 0), // Gregorian: 10/09/2008
new TestCase(2454719.5, 0, 7500, 13, 5, WED, 0, 0, 0) };
EthiopicCalendar testCalendar = new EthiopicCalendar();
testCalendar.setLenient(true);
doTestCases(tests, testCalendar);
// Testing Amete Alem mode
EthiopicCalendar testCalendarAmeteAlem = new EthiopicCalendar();
testCalendarAmeteAlem.setAmeteAlemEra(true);
testCalendarAmeteAlem.setLenient(true);
doTestCases(testsAmeteAlem, testCalendarAmeteAlem);
}
use of android.icu.util.EthiopicCalendar in project j2objc by google.
the class EthiopicTest method newAmeteAlemEraCalendar.
private static EthiopicCalendar newAmeteAlemEraCalendar() {
EthiopicCalendar alemawiCalendar = new EthiopicCalendar();
alemawiCalendar.setAmeteAlemEra(true);
return alemawiCalendar;
}
Aggregations