xf:remove-timezone-from-dateTime

Removes a time zone from a dateTime value. The dateTime value with a time zone is localized to either the implicit time zone or to time zone specified by the argument: $dayTimeDuration-var and then the timezone indicator is removed.

If the specified dateTime value has no time zone associated with it, then the implicit time zone is added to dateTime value before the localization described above is done. Since the purpose of the remove-timezone-to-dateTime function is to remove a timezone from a dateTime value with a timezone, in most cases the passed in dateTime value (argument: $dateTime-var) will have a time zone, so this step will be ignored as shown in the preceding examples.

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.

Signatures

xf:remove-timezone-from-dateTime(xs:dateTime $dateTime-var) —> xs:dateTime

xf:remove-timezone-from-dateTime(xs:dateTime $dateTime-var, xf:dayTimeDuration, $dayTimeDuration-var) —> xs:dateTime

Arguments

Data Type
Argument
Description

xs:dateTime?

$dateTime-var

Contains a representation of the date and time.

xf:dayTimeDuration

$dayTimeDuration-var

Time zone to remove from $dateTime-var. (Optional, if not specified the implicit time zone is used).

Returns

Returns a dateTime without a time zone.

If $dateTime-var does not contain a time zone and optional argument $dayTimeDuration-var is not specified, the passed in date and time are returned with no conversion.

Examples

Removing the Specified Timezone From a dateTime Value

The following example removes the specified time zone from the specified dateTime value.

In this example, the passed in dateTime value: 2002-12-06T12:00:00Z is specified with the UTC time zone specified by the time zone indicator: Z.

The time zone is specified with the dayTimeDuration string: -PT7H, in the preceding query which is the Pacific Daylight Savings Time (PST) time zone (-07:00).

The passed in dateTime value: 2002-12-06T12:00:00Z specified with the UTC time zone is localized to PST time zone and the time zone indicator (Z) is removed, as shown in the following example query:

let $dateTimeWithUTCTimezone := xs:dateTime("2002-12-06T12:00:00Z")
return
<result>
	<dateTimeWithUTCTimezone>{$dateTimeWithUTCTimezone}</dateTimeWithUTCTimezone>
	<dateTimeWithTimeZoneAdded>{ xf:remove-timezone-from-dateTime(xs:dateTime($dateTimeWithUTCTimezone, 
	xf:dayTimeDuration("-PT7H"))) }</dateTimeWithTimeZoneAdded>
</result> 

The preceding query produces the following result:

<result>
	<dateTimeWithUTCTimezone>2002-12-06T12:00:00Z</dateTimeWithUTCTimezone>
	<dateTimeWithTimeZoneAdded>2002-12-06T05:00:00</dateTimeWithTimeZoneAdded>
</result> 

Removing the Implicit Timezone From the dateTime Value

The following example removes the implicit time zone from the specified dateTime value. In this example, the passed in dateTime value: 2002-12-06T12:00:00Z is specified with the UTC time zone specified by the time zone indicator: Z.

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.)

The passed in dateTime value: 2002-12-06T12:00:00Z specified with the UTC time zone is localized to PST time zone and the time zone indicator (Z) is removed, as shown in the following example query:

let $dateTimeWithUTCTimezone := xs:dateTime("2002-12-06T12:00:00Z")
return
<result>
	<dateTimeWithUTCTimezone>{$dateTimeWithUTCTimezone}</dateTimeWithUTCTimezone>
	<dateTimeWithTimeZoneAdded>{ xf:remove-timezone-from-dateTime(xs:dateTime($dateTimeWithUTCTimezone)) }
	</dateTimeWithTimeZoneAdded>
</result> 

The preceding query produces the following result:

<result>
	<dateTimeWithUTCTimezone>2002-12-06T12:00:00Z</dateTimeWithUTCTimezone>
	<dateTimeWithTimeZoneAdded>2002-12-06T05:00:00</dateTimeWithTimeZoneAdded>
</result> 

Related Topics

W3C remove-timezone-from-dateTime function description.

W3C dateTime data type description.

W3C dayTimeDuration operator description.