summaryrefslogtreecommitdiffstats
path: root/tests/auto/qglbuffer
diff options
context:
space:
mode:
authorJohn Layt <john@layt.net>2010-03-30 10:55:33 +0200
committerOlivier Goffart <ogoffart@trolltech.com>2010-03-30 10:56:24 +0200
commit568475d98d77c3ade027eb88e571ca8b84088002 (patch)
tree8f139c3b9b7722f572ba65b1281e6c020b59fd4c /tests/auto/qglbuffer
parentbc4fe607fe65dca24460d4f612c5815b4767e988 (diff)
Fix QDate::isLeapYear() for years < 1
The current formula for isLeapYear() assumes that years -4, -8, etc are leap years in the Julian Calendar. This is not the case, leap years in fact fall in -1, -5, -9, etc as there is no year 0 in the Julian Calendar (count back 4 years from 4AD to confirm). The julianDayFromDate() and getDateFromJulianDay() functions correctly calculate this, but isValid() uses isLeapYear() and so causes setDate() to incorrectly reject valid dates. Sample test code to round-trip a jd to ymd and back to jd: QDate testDate; QDate loopDate = QDate::fromJulianDay(1); while ( loopDate.toJulianDay() <= 5373484 ) { // <= 9999-12-31 testDate.setDate( loopDate.year(), loopDate.month(), loopDate.day() ); if ( !testDate.isValid() || loopDate != testDate ) { qDebug() << "Round Trip failed : " << loopDate.toJulianDay() << " = " << loopDate.year() << loopDate.month() << loopDate.day() << " = " << testDate.toJulianDay(); } loopDate.addDays(1); } Before the fix, 29 Feb 1 BC (year = -1) and all other BC leap days returned by year() month() day() would result in setDate() failing. After the fix the round trip works fine. Merge-request: 2282 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'tests/auto/qglbuffer')
0 files changed, 0 insertions, 0 deletions