ICU-6887 Fix bad DOM calculation in Islamic calendar

X-SVN-Rev: 27666
This commit is contained in:
John Emmons 2010-02-25 00:06:49 +00:00
parent 078862d761
commit b8f99118cc
2 changed files with 14 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2008, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -438,7 +438,7 @@ public class IslamicCalendar extends Calendar {
{
// Make a guess at when the month started, using the average length
long origin = HIJRA_MILLIS
+ (long)Math.floor(month * CalendarAstronomer.SYNODIC_MONTH - 1) * ONE_DAY;
+ (long)Math.floor(month * CalendarAstronomer.SYNODIC_MONTH) * ONE_DAY;
double age = moonAge(origin);
@ -610,7 +610,7 @@ public class IslamicCalendar extends Calendar {
monthStart = (long)Math.floor(months * CalendarAstronomer.SYNODIC_MONTH - 1);
if ( days - monthStart >= 28 && moonAge(internalGetTimeInMillis()) > 0) {
if ( days - monthStart >= 25 && moonAge(internalGetTimeInMillis()) > 0) {
// If we're near the end of the month, assume next month and search backwards
months++;
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -143,6 +143,16 @@ public class IslamicTest extends CalendarTest {
IslamicCalendar islamic = newCivil();
doLimitsTest(islamic, null, cal.getTime());
doTheoreticalLimitsTest(islamic, true);
// number of days to test - Islamic calendar starts to exhibit
// rounding errors after year AH3954 - about 2500 years out.
IslamicCalendar islamic2 = new IslamicCalendar();
islamic2.setCivil(false);
int testTime = getInclusion() <= 5 ? 20000 : 800000;
doLimitsTest(islamic2, null, cal.getTime(), testTime);
doTheoreticalLimitsTest(islamic2, true);
}
public void TestCoverage() {