Name
[2.0]
adjust-date-to-timezone()
Adjusts an xs:date value to a particular
timezone.
Syntax
xs:date?adjust-date-to-timezone(xs:date?)xs:date?adjust-date-to-timezone(xs:date?,$timezone as xs:dayTimeDuration)
Input
An optional xs:date value
and an optional xs:dayTimeDuration. If no xs:date is provided, the empty sequence
is returned. If an xs:dayTimeDuration is provided, the date
is adjusted to the timezone it contains; otherwise, the XSLT
processor uses the default timezone as returned by [2.0]
implicit-timezone(). Finally, if the timezone
provided by the xs:dayTimeDuration is the empty
sequence, the function returns the date with the timezone
information removed.
Output
An xs:date 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
Here’s a stylesheet that uses the adjust-date-to-timezone() in several
ways:
<?xml version="1.0"?>
<!-- adjust-date-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" select="xs:dayTimeDuration('-PT6H')"/> <xsl:variable name="minusTen" select="xs:dayTimeDuration('-PT10H')"/> <xsl:variable name="LilysBirthday" as="xs:date" select="xs:date('1995-04-21')"/> ...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