Question

Is it possible in XSLT to retrieve the time zone offset for a particular locale? There is a function named in-summer-time which takes in a dateTime and a locale identifier. It returns whether the given date falls under daylight savings or not for that country.

I have a requirement where I need to calculate the offset time for a particular locale. For example, I get the local time at Chile and I need to convert it to local time in UK. I can make use of the function in-summer-time to calculate for the daylight adjustments. But, where can I get the actual offset time for Chile?

P.S.: the function adjust-time-to-timezone does not help since it requires the offset time to be passed into the function(like 2013-05-10T08:10:30-05:00). I do not have the offset time (-05:00) information before hand.

Était-ce utile?

La solution

There's a Saxon extension function

saxon:adjust-to-civil-time

See http://www.saxonica.com/documentation/index.html#!functions/saxon/adjust-to-civil-time

Which looks as if it might serve the purpose.

(The heading giving the function signature in the documentation is wrong.)

For example

saxon:adjust-to-civil-time(xs:dateTime('2013-12-06T12:00:00Z'), 'America/Santiago')

returns

2013-12-06T09:00:00-03:00

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top