format-dateTime() conventional timezone name
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 3
- Joined: Mon Feb 23, 2009 4:46 pm
format-dateTime() conventional timezone name
I'm trying to get the timezone name using format-dateTime(), following an adjust-dateTime-to-timezone(), in Saxon 9 (whatever version ships with oXygen 10).
with Saxon 8.7 I could do :
declaring xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"
The [ZN,*-3] bit would output est.
With Saxon 9 :
declaring xmlns:xs="http://www.w3.org/2001/XMLSchema"
The [ZN,*-3] bit outputs -05:00.
with Saxon 8.7 I could do :
declaring xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"
Code: Select all
<xsl:variable name="est-time" select="adjust-dateTime-to-timezone(current-dateTime(), xdt:dayTimeDuration('-PT5H'))"/>
<xsl:value-of selEST="format-dateTime($est-time, '[D] [MN,*-3] [Y] [h]:[m01][PN,*-2] [ZN,*-3]')"/>
With Saxon 9 :
declaring xmlns:xs="http://www.w3.org/2001/XMLSchema"
Code: Select all
<xsl:variable name="dateTime" select="current-dateTime()"/>
<xsl:variable name="est-zone" select="xs:dayTimeDuration('-PT5H')"/>
<xsl:variable name="est" select="adjust-dateTime-to-timezone($dateTime, $est-zone)"/>
<xsl:value-of select="format-dateTime($est, '[D] [MN,*-3] [Y] [h01]:[m01] [PN, *-2] [ZN,*-3]')"/>
-
- Posts: 3
- Joined: Mon Feb 23, 2009 4:46 pm
Re: format-dateTime() conventional timezone name
I contacted Saxon support directly and got the reply below, pretty quick too. I guess it'll be useful to someone else having the same problem.
Timezone names vary depending what part of the world you are in. To get the names used in the US, please set the country argument of format-dateTime() to "us", thus:
Code: Select all
format-dateTime($est-time, '[D] [MN,*-3] [Y] [h]:[m01][PN,*-2] [ZN,*-3]', (), (), 'us')
Saxon now also uses the Java database of daylight savings time changes, so if it is known that your date falls within US summer-time, the timezone -05:00 will be displayed as CDT.
Michael Kay
http://www.saxonica.com/
-
- Posts: 3
- Joined: Mon Feb 23, 2009 4:46 pm
Re: format-dateTime() conventional timezone name
further to the above topic . . .
The country parameter should give the location where the event in question took place, it's not the locale of the user of the information. (In fact, timezone formatting is the only thing Saxon uses it for; it was provided primarily for use with non-Gregorian calendars where the translation from Gregorian to another calendar may be location-dependent.)
Timezone -5 never occurs in the UK, and we don't have a name for it; or rather, we call it EST if it happened in New York in winter, CDT if it happened in Chicago in summer, COT if it happened in Colombia, AST if it happened in Brazil, and so on. Hence the need to know where it happened.
Really this is a bit of a mess. The xs:dateTime data type only carries information about UTC offset, not about civil time zone. But format-dateTime requires a civil time zone to be output. So Saxon does its best to guess.
Michael Kay
http://www.saxonica.com/
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: format-dateTime() conventional timezone name
Post by sorin_ristache »
Thank you delirio for the details.
Regards,
Sorin
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service