Adds a time zone to a dateTime value. The timezone added to the dateTime value is either the implicit time zone or passed in with the optional argument: $dayTimeDuration-var.
Note: The implicit time zone is obtained from the current environment. For example, if the time zone specified on your machine is the PSD (Pacific Daylight Savings), the implicit time zone would be -07:00.
Adds a time zone to a dateTime value by invoking the following steps:
xf:add-timezone-to-dateTime(xs:dateTime $dateTime-var) —> xs:dateTime
xf:add-timezone-to-dateTime(xs:dateTime $dateTime-var, xf:dayTimeDuration, $dayTimeDuration-var) —> xs:dateTime
Time zone to add to $dateTime-var. (Optional, if not specified the implicit time zone is used). |
Returns a dateTime with a time zone.
If $dateTime-var contains a time zone and the optional argument $dayTimeDuration-var is not specified, the passed in date and time are returned with no conversion.
The following example adds the specified time zone to the specified dateTime value. In this example, the specified dateTime value: 2002-12-06T12:00:00, initially does not have a timezone zone associated with it.
Adding the specified time zone to the specified dateTime value, by invoking xf:add-timezone-to-dateTime(xs:dateTime("2002-12-06T12:00:00", dayTimeDuration("-PT7H"))), causes the following internal conversion steps:
let $dateTimeWithNoTimezone := xs:dateTime("2002-12-06T12:00:00") return <result> <dateTimeWithNoTimezone>{$dateTimeWithNoTimezone}</dateTimeWithNoTimezone> <dateTimeWithTimeZoneAdded>{ xf:add-timezone-to-dateTime(xs:dateTime($dateTimeWithNoTimezone), xf:dayTimeDuration("-PT7H")) }</dateTimeWithTimeZoneAdded> </result>
The preceding query produces the following result:
<result> <dateTimeWithNoTimezone>2002-12-06T12:00:00</dateTimeWithNoTimezone> <dateTimeWithTimeZoneAdded>2002-12-06T19:00:00Z</dateTimeWithTimeZoneAdded> </result>
Note: The Z at the end of the 2002-12-06T19:00:00Z value specifies that the dateTime value is in UTC time.
The following example adds the implicit time zone to the specified dateTime value. In this example, the specified dateTime value: 2002-12-06T12:00:00, initially does not have a timezone zone associated with it.
In this example, the implicit time zone is assumed to be -07:00, the Pacific Daylight Savings Time (PST) time zone. (The implicit time zone is the default time zone for the current machine.)
Adding the implicit time zone to the specified dateTime value, by invoking xf:add-timezone-to-dateTime(xs:dateTime("2002-12-06T12:00:00")), causes the following internal conversion steps:
let $dateTimeWithNoTimezone := xs:dateTime("2002-12-06T12:00:00") return <result> <dateTimeWithNoTimezone>{$dateTimeWithNoTimezone}</dateTimeWithNoTimezone> <dateTimeWithTimeZoneAdded>{ xf:add-timezone-to-dateTime(xs:dateTime($dateTimeWithNoTimezone)) } </dateTimeWithTimeZoneAdded> </result>
The preceding query produces the following result:
<result> <dateTimeWithNoTimezone>2002-12-06T12:00:00</dateTimeWithNoTimezone> <dateTimeWithTimeZoneAdded>2002-12-06T19:00:00Z</dateTimeWithTimeZoneAdded> </result>
Note: The Z at the end of the 2002-12-06T19:00:00Z value specifies that the dateTime value is in UTC time.
Note: The results of this query maybe be different for your machine because the implicit time zone may be different.
W3C add-timezone-to-dateTime function description.
W3C dateTime data type description.
W3C dayTimeDuration operator description.