adjust-dateTime-to-timezone function
The fn:adjust-dateTime-to-timezone function adjusts an xs:dateTime value for a specific time zone or removes the time zone component from the value.
Syntax
- dateTime-value
- The dateTime value that is to be adjusted.
dateTime-value is of type xs:dateTime, or is an empty sequence.
- timezone-value
- A duration that represents the time zone to which dateTime-value is
to be adjusted.
timezone-value can be an empty sequence or a single value of type xdt:dayTimeDuration between -PT14H and PT14H, inclusive. The value can have an integer number of minutes and must not have a seconds component. If timezone-value is not specified, the default value is PT0H, which represents UTC.
Returned value
The returned value is either a value of type xs:dateTime or is an empty sequence depending on the types of input values. If dateTime-value is not an empty sequence, the returned value is of type xs:dateTime. The following table describes the possible returned values:
dateTime-value | timezone-value | Returned value |
---|---|---|
dateTime-value that contains a timezone component | An explicit value, or no value specified (duration of PT0H) | The dateTime-value adjusted to the time zone represented by timezone-value. The returned value contains the timezone component represented by timezone-value. |
dateTime-value that contains a timezone component | An empty sequence | The dateTime-value with no timezone component. |
dateTime-value that does not contain a timezone component | An explicit value, or no value specified (duration of PT0H) | The dateTime-value with a timezone component. The timezone component is the time zone represented by timezone-value. The date and time components are not adjusted to the time zone. |
dateTime-value that does not contain a timezone component | An empty sequence | The dateTime-value. |
An empty sequence | An explicit value, empty sequence, or no value specified | An empty sequence. |
Examples
In the following examples, the
variable $tz
is a duration of -10 hours, defined
as xdt:dayTimeDuration("-PT10H")
.
The following function adjusts the dateTime of March 7, 2002 at 10 am in the UTC-7 time zone to the timezone specified by timezone-value of -PT10H.
fn:adjust-dateTime-to-timezone(xs:dateTime("2002-03-07T10:00:00-07:00"), $tz)
The returned dateTime is 2002-03-07T07:00:00-10:00.
The following function adjusts the dateTime value for March 7, 2002 at 10 am. The dateTime-value does not have a timezone component, and the function specifies a timezone-value of -PT10H.
fn:adjust-dateTime-to-timezone(xs:dateTime("2002-03-07T10:00:00"), $tz)
The returned dateTime is 2002-03-07T10:00:00-10:00.
In the following function adjusts the dateTime value for June 4, 2006 at 10 am in the UTC-7 time zone. Without a timezone-value specified, the function uses the default timezone value of PT0H.
fn:adjust-dateTime-to-timezone(xs:dateTime("2006-06-04T10:00:00-07:00"))
The returned dateTime is 2006-06-04T17:00:00Z, the dateTime adjusted to UTC.
The following function removes the timezone component from the dateTime value for March 7, 2002 at 10 am in the UTC-7 time zone. The timezone-value value is the empty sequence.
fn:adjust-dateTime-to-timezone(xs:dateTime("2002-03-07T10:00:00-07:00"), ())
The returned dateTime is 2002-03-07T10:00:00.