Re: Functions on Dates, Times and Durations

Bernhard Bodenstorfer wrote:

> The origin of most problems with durations is that
> they depend on a reference dateTime so that they can
> be unambiguously interpreted.
> 

The origin of all problems with durations is that durations
(I mean xs:duration) are conceptually lame!

As long as a duration involves only seconds, minutes, hours, and days
it is OK, it is just a syntactically equivalent way of representing
a numeric duration in seconds (seconds are the legal unit for time).

As soon as a duration involves months, it is no more OK, because a month
is a fuzzy concept, something that lasts 28, 29, 30 or 31 days.
And you are right, it is not possible to know the exact duration of
a month without a reference date.
[I feel I am just repeating obvious facts.]

Then a sane approach of the question should be to avoid manipulating
xs:duration as much as possible and to perform all computations with
numeric durations in seconds.

A complementary requirement is the capability to convert durations
from and to numeric values, and to provide duration/date/time
formatting functions. As I understand it, this is the point
of view upheld by Michael Kay, and it seems sensible.

On the contrary, the F&O WG has chosen to provide an arithmetic
based exclusively on duration types. This seems to be based on
considerations of compatibility with legacy languages like
SQL (which has no less than 4 different types of durations!)

Since xs:duration has proved intractable, the WG has gone further
in the direction of complexity, and introduced two new subtypes
supporting complex and rather odd arithmetic operations.

[By the way this replacement of xs:duration by new types invalidates
any argument of compatibility with legacy data...]

Meanwhile, several issues remain virtually unaddressed
in XPath/XQuery:

- how to convert duration types to numeric values usable in
   'real world' calculations (financial, scientific)
- how to construct duration/time/dates from numeric values
   (this is very important for real calculations and also
   for converting durations/times/dates from localized formats)
- how to format durations/times/dates in misc. formats


I think it would be quite valuable to collect a number of
real-life use-cases and see how they are solved by the
current specifications or outsider proposals (that is, to write
actual code snippets and see how they look).

-- 
Xavier FRANC

Received on Friday, 19 December 2003 17:27:41 UTC