Timezones in get-hours-from-dateTime etc.

Xavier Franc, in message

 http://lists.w3.org/Archives/Public/public-qt-comments/2003Sep/0124.html

suggested that the date/time component extraction functions (for example,
get-hours-from-dateTime()) should return components of the localized time,
rather than the normalized time.

(Terminology: localized time = the time in the timezone represented by the
timezone component of the value; normalized time = the same instant of time
represented in timezone UTC)

On reflection, I'm inclined to agree with Xavier: I think we have got this
wrong. The date/time is presented in localized form when converting it to a
string, and when using the XSLT format-dateTime() family of functions. I
think it will be less confusing if we consistently present date/time values
in the localized form, and require users to use adjust-X-to-timezone if they
want something different.

Currently, if you want the components of the localized value, you have to
call adjust-dateTime-to-timezone() with () as the second argument, and then
call get-hours-from-dateTime. 

With this change, a user who wanted components of the normalized value would
use adjust-dateTime-to-timezone() to adjust the timezone to UTC, and then
extract the component values.

Specifically (in XQuery syntax):

let $utc := xdt:dayTimeDuration("PT0H"),
    $ndt := adjust-dateTime-to-timezone($in, $utc) return
    get-hours-from-dateTime($ndt)

We might also want to consider changing the default for the second argument
of adjust-X-to-timezone() so it adjusts to UTC, since adjusting to the local
timezone can easily be achieved by supplying implicit-timezone() as the
second parameter. Alternatively, if my proposal on durations is accepted,
then adjust-dateTime-to-timezone($in, 0) will return the normalized value.

Michael Kay

Received on Thursday, 2 October 2003 07:35:15 UTC