Name
[2.0]
adjust-dateTime-to-timezone()
Adjusts an xs:dateTime value to a particular
timezone.
Syntax
xs:dateTime?adjust-dateTime-to-timezone(xs:dateTime?)xs:dateTime?adjust-dateTime-to-timezone(xs:dateTime?,$timezone as xs:dayTimeDuration?)
Inputs
An optional xs:dateTime
value and an optional xs:dayTimeDuration. If no xs:dateTime is
provided, the empty sequence is returned. If an xs:dayTimeDuration is supplied, the
xs:dateTime value is adjusted to the
timezone it contains. Otherwise, adjust-dateTime-to-timezone() adjusts the
xs:dateTime value to the
default timezone as returned by [2.0]
implicit-timezone(). Finally, if the timezone
provided is the empty sequence, the function returns the xs:dateTime with the timezone
information removed.
Output
The given xs:dateTime
value adjusted to the appropriate timezone.
Defined in
XQuery 1.0 and XPath 2.0 Functions and Operators section 10.7, “Timezone Adjustment Functions on Dates and Time Values.”
Example
This stylesheet uses adjust-dateTime-to-timezone() in
several different ways. The default timezone here is GMT -4,
representing Eastern Daylight Time (EDT).
<?xml version="1.0"?>
<!-- adjust-datetime-to-timezone.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="gmt" select="xs:dayTimeDuration('PT0H')"/> <xsl:variable name="est" select="xs:dayTimeDuration('-PT5H')"/> <xsl:variable name="cst" ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access