W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 2001

Comparing durations

From: <zongaro@ca.ibm.com>
Date: Wed, 4 Apr 2001 16:26:27 -0400
To: www-xml-schema-comments@w3.org
Message-ID: <OF1341CECF.9961FBEE-ON85256A24.006BF95B@torolab.ibm.com>


     I have a comment on what appears to be an edge case that was missed in
the definition of the order relation on duration [1].

     My understanding is that the dates chosen to define the order relation
were selected so that, given any duration expressed in months and years,
the duration beginning at one of those dates would require a maximum number
of days and the duration beginning at another would require a minimum
number of days.  The dates chosen take into account that 1700, 1800 and
1900 were not leap years.

     If I understand the definitions of dateTime, duration, et al.
correctly, they are treated as if the Gregorian calendar existed prior to
October 15, 1582.  If that is correct, a problem comes from the fact that
the calendar goes from 1 BC to AD 1, without a Year 0.  Thus, there is no
century year between 399 BC and AD 399 that is a leap year according to the
Gregorian calendar.  Normally, there is a century year that is a leap year
every 400 years, but in this case the calendar goes 798 years without a
century year that is a leap year.

     I believe I have an example that demonstrates the problem, assuming
I've done the math correctly.  If you compare the durations P797Y and
P291098D, you get the following result.  (I've omitted the "T00:00:00Z"
from each dateTime to save space.)  The first column lists the dateTime
values specified in; the second and fourth columns list the value
of the first column plus the durations P797Y and P291098D, respectively;
and the third column shows the relation between the two values.

                |   +P797Y   |   | +P291098D
     1696-09-01 | 2493-09-01 | = | 2493-09-01
     1697-02-01 | 2494-02-01 | = | 2493-02-01
     1903-03-01 | 2700-03-01 | > | 2700-02-28
     1903-07-01 | 2700-07-01 | > | 2700-06-30

This implies that P797Y >= P291098D.  However, if you add those durations
to -0399-03-01, you see that P797Y <> P291098D.

                 |   +P797Y  |   | +P291098D
     -0399-03-01 | 399-03-01 | < | 399-03-02

     My apologies if there is an error in my understanding, reasoning or

[1] http://www.w3.org/TR/xmlschema-2/#duration


Henry Zongaro      XML Parsers development
IBM SWS Toronto Lab   Tie Line 778-6044;  Phone (416) 448-6044
Received on Wednesday, 4 April 2001 16:25:45 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:08:52 UTC