# Re: Length of a day.

From: <zongaro@ca.ibm.com>
Date: Thu, 20 Dec 2001 11:22:06 -0500

Message-ID: <OF2AF7860C.098DD188-ON85256B28.0057DC4B@torolab.ibm.com>
```Hi Eric,

On October 29, 2001 you wrote[1]:

--- Excerpt from Eric's note ---
> Note that leap seconds screw up minutes,
> hours and days.

Yes, and doesn't this means that the algorithm that add durations to
dateTimes and considers that there are only two groups of values
"Essentially, this calculation is equivalent to separating D into
<year,month> and <day,hour,minute,second> fields" is not 100% exact?

This algorithm considers that the only variable quotients between
datetime parts is between the groups <year,month> and
<day,hour,minute,second> and from what you're saying, there should be
three groups: <year,month>, <day> and <hour,minute,second>.
--- End of excerpt from Eric's note ---

You are correct that the algorithm in Appendix E of "XML Schema:
Datatypes" doesn't account for leap seconds, but that was a conscious
decision on the part of the Schema Working Group.  It's difficult to
imagine any other convenient way of dealing with the problem.  E.1 [2]
points out that:

Leap seconds are handled by the computation by treating them as overflows.
Essentially, a value of 60 seconds in S is treated as if it were a
duration of 60 seconds added to S (with a zero seconds field). All
calculations thereafter use 60 seconds per minute.
Thus the addition of either PT1M or PT60S to any dateTime will always
produce the same result. This is a special definition of addition which is
designed to match common practice, and -- most importantly -- be stable
over time.
A definition that attempted to take leap-seconds into account would need
to be constantly updated, and could not predict the results of future

Thanks,

Henry
[1]