This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Step 3a of http://www.w3.org/TR/xmlschema11-2/#vp-dt-timeOnTimeline (leap-year days correction) does not take into account the fact that 1BCE (='0000' in dateTime lexical form) is a leap year. As a result, the calculated time-on-timeline value is off by one day for all BCE dates. Applying the algorithm as written, I came up with the following timeline values: ToTl("0001-01-01T00:00:00Z") = 0 ToTl("0000-12-31T00:00:00Z") = 0 (should be -86400) I believe the following modifications to the ToTl will correct this problem: 1. Remove the -1 offset from the definition of yr: * Let yr be 1972 when dt's year is absent, and dt's year otherwise. 2. Include the -1 offset in step 2a: * Set ToTl to 31536000 x (yr - 1) 3. Change the leap-year adjustment in step 3a as follows: * Add 86400 * ((yr - 4) div 4 - (yr - 100) div 100 + (yr - 400) div 400) to ToTl
The discrepancy is due to the fact that my implementation of the algorithm was in Java, which uses a different implementation of integer division (negative quotients are rounded up, not down) than what is specified by XSD. Changing my implementation to correctly implement XSD div for negative quotients yields correct results for BCE years.