home contribute faq download

FunctX XQuery Functions

fn:adjust-date-to-timezone

Adjusts a date to a specific timezone, or no timezone

Google
Webxqueryfunctions.com

Description

The fn:adjust-date-to-timezone function behaves differently depending on whether the $arg date value already has a time zone, and on the value of the time zone provided.

The $timezone argument is expressed as an xs:dayTimeDuration, for example -PT5H for US Eastern Standard Time. If $timezone is the empty sequence, it is assumed that the desired result is a date value that is in no time zone. If $timezone is omitted from the function call, it is assumed to be the implicit time zone.

The $arg date is assumed for the sake of time zone calculation to be just like an xs:dateTime value whose time is midnight (00:00:00). If $arg does not already have a time zone, its date part stays the same, but it is now associated with the specified time zone.

If $arg already has a time zone, its value is adjusted to that time zone.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$arg xs:date? the date to adjust
$timezone xs:dayTimeDuration? the timezone to adjust it to
return value xs:date?

Examples

XQuery ExampleResults
adjust-date-to-timezone(
   xs:date('2006-02-15'),
   xs:dayTimeDuration('-PT8H'))
2006-02-15-08:00
adjust-date-to-timezone(
   xs:date('2006-02-15-03:00'),
   xs:dayTimeDuration('-PT8H'))
2006-02-14-08:00
adjust-date-to-timezone(
   xs:date('2006-02-15'), ())
2006-02-15
adjust-date-to-timezone(
   xs:date('2006-02-15-03:00'), ())
2006-02-15
The following examples assume an implicit time zone of -05:00:
adjust-date-to-timezone(
   xs:date('2006-02-15'))
2006-02-15-05:00
adjust-date-to-timezone(
   xs:date('2006-02-15-03:00'))
2006-02-14-05:00 

See Also

fn:adjust-dateTime-to-timezoneAdjusts a dateTime to a specific timezone, or no timezone
fn:adjust-time-to-timezoneAdjusts a time to a specific timezone, or no timezone

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery