This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 13260 - dateTime time-on-timeline incorrect for BCE years?
Summary: dateTime time-on-timeline incorrect for BCE years?
Status: RESOLVED INVALID
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Datatypes: XSD Part 2 (show other bugs)
Version: 1.1 only
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: David Ezell
QA Contact: XML Schema comments list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-14 20:12 UTC by Alex Hall
Modified: 2011-07-14 21:48 UTC (History)
1 user (show)

See Also:


Attachments

Description Alex Hall 2011-07-14 20:12:45 UTC
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
Comment 1 Alex Hall 2011-07-14 21:48:44 UTC
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.