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 2221 - R-229: Order relation on time
Summary: R-229: Order relation on time
Status: CLOSED WONTFIX
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Datatypes: XSD Part 2 (show other bugs)
Version: 1.0 only
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: XML Schema comments list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-14 19:21 UTC by Sandy Gao
Modified: 2009-04-21 19:25 UTC (History)
0 users

See Also:


Attachments

Description Sandy Gao 2005-09-14 19:21:43 UTC
Several readers have found that section 3.8 of XML Schema 1.0 Part 2 leaves 
some uncertainty as to the exact nature of the order relation on time values. 
The text says: 

Since the lexical representation allows an optional time zone indicator, time 
values are partially ordered because it may not be able to determine the order 
of two values one of which has a time zone and the other does not. The order 
relation on time values is the Order relation on dateTime (section 3.2.7.3) 
using an arbitrary date. See also Adding durations to dateTimes (appendix E). 
Pairs of time values with or without time zone indicators are totally ordered. 

Here is an example that illustrates the potential for misinterpretation. Two 
different answers are possible to a given ordering question, depending on how 
the specification is interpreted. 

Question: Is 09:00:00+12:00 < 09:00:00-12:00? 

It seems clear that the correct answer is no, since section 3.2.8 of XML Schema 
1.0 Part 2 says "time represents an instant of time that recurs every day". 
These two time values are 24 hours apart, so they should be equal. But some 
interpretations of the order relation for time values produces different 
answers. 

Answer 1: 

Step 1: Assign an arbitrary date to both time values: 
Is dateTime 2002-02-16T09:00:00+12:00 < 2002-02-16T09:00:00-12:00? 
Step 2: Apply the Order relation on dateTime: 
Step 2A: Since both dateTimes contain a timezone, normalize them to Z: Is 
dateTime 2002-02-15T21:00:00Z < 2002-02-16T21:00:00Z? 
Step 2B: Since both dateTimes contain a timezone, compare P and Q field by 
field from the year field down to the second field. Since the day field of the 
first value (15) is less than the day field of the second value (16), the 
answer is true (that is, the first time value is less than the second one). 

Answer 2: 

Step 1: Normalize the time values to Z: 
Is 21:00:00Z < 21:00:00Z? 
Step 2: Assign an arbitrary date to both time values: Is dateTime 2002-02-
16T21:00:00Z < 2002-02-16T21:00:00Z? 
Step 3: Apply the Order relation on dateTime: 
Step 3A: Since both dateTimes contain a timezone, normalize them to Z: 
No change. 
Step 3B: Since both dateTimes contain a timezone, compare P and Q field by 
field from the year field down to the second field. Since all fields in the 
values are identical, the answer is false (the first time value is not less 
than the second one). 

As stated above, I believe that the second answer (and the second algorithm) is 
correct. It must be, otherwise the definition of time values would be violated 
(because these two time values which are clearly identical under the definition 
of the type would not be equal under the order relation). 

However, the algorithm I described for calculating answer 2 above is not easily 
inferred from the specification. The specification says "The order relation on 
time values is the Order relation on dateTime (section 3.2.7.3) using an 
arbitrary date." We believe that this means that for time values with time 
zones, you must normalize the dates into a single 24 hour period before 
applying the Order relation on dateTime. An easy way to do this is to normalize 
the time values to UTC and then assign an arbitrary year-month-day value to 
them. But a more natural interpretation of the spec would be to skip the 
normalization step and just assign the year-month-day value. This will probably 
work just fine until you encounter a situation like the one given above. We ran 
into this while working on an XACML implementation (which uses the XML Schema 
ordering for time values). 

We suggest adding text to the XML Schema specification to make it easier for 
implementors to understand the proper interpretation of the spec. After the 
sentence that ends with "using an arbitrary date", we would suggest adding a 
sentence that says "Before assigning this arbitrary date, time values with a 
time zone must be normalized to UTC." 

See:
http://lists.w3.org/Archives/Public/www-xml-schema-comments/2003JulSep/0039.html
Comment 1 Dave Peterson 2005-10-14 00:59:58 UTC
(In reply to comment #0)

> Question: Is 09:00:00+12:00 < 09:00:00-12:00? 

> Answer 1: 
> 
> Step 1: Assign an arbitrary date to both time values: 
> Is dateTime 2002-02-16T09:00:00+12:00 < 2002-02-16T09:00:00-12:00? 

Fallacious.  The two ("both") time values are values, not lexical representations
thereof.  The values don't have timezones in Schema 1.0.  So you can't go down
the "Answer 1" path.
Comment 2 Sandy Gao 2005-10-28 19:03:42 UTC
Discussed at 2005-10-28 telecon [1].

Resolution: Close with no further action: RESOLVED, WONTFIX.

[1] http://lists.w3.org/Archives/Member/w3c-xml-schema-ig/2005Oct/0022.html
Comment 3 C. M. Sperberg-McQueen 2005-12-09 20:54:05 UTC
See also email from Dave Peterson responding to the commentator
on behalf of the WG, at 
http://lists.w3.org/Archives/Public/www-xml-schema-comments/2005OctDec/0172.html