fn:adjust-date-to-timezone( $arg as xs:date?, [$timezone as xs:dayTimeDuration?] ) as xs:date?
Adjusts an xs:date value to a specific timezone, or to no timezone at all. If $timezone is the empty sequence, returns an xs:date without a timezone. Otherwise, returns an xs:date with a timezone. For purposes of timezone adjustment, an xs:date is treated as an xs:dateTime with time 00:00:00.
If $timezone is not specified, then $timezone is the value of the implicit timezone in the dynamic context.
If $arg is the empty sequence, then the result is the empty sequence.
A dynamic error is raised [err:FODT0003] if $timezone is less than -PT14H or greater than PT14H or if does not contain an integral number of minutes.
If $arg does not have a timezone component and $timezone is the empty sequence, then the result is $arg.
If $arg does not have a timezone component and $timezone is not the empty sequence, then the result is $arg with $timezone as the timezone component.
If $arg has a timezone component and $timezone is the empty sequence, then the result is the localized value of $arg without its timezone component.
If $arg has a timezone component and $timezone is not the empty sequence, then:
Let $srcdt be an xs:dateTime value, with 00:00:00 for the time component and date and timezone components that are the same as the date and timezone components of $arg.
Let $r be the result of evaluating fn:adjust-dateTime-to-timezone($srcdt, $timezone)
The result of this function will be a date value that has date and timezone components that are the same as the date and timezone components of $r.
Parameters | |
---|---|
arg | The date to adjust to the new timezone. |
timezone | The new timezone for the date. |
Assume the dynamic context provides an implicit timezone of -05:00 (-PT5H0M). fn:adjust-date-to-timezone(xs:date("2002-03-07")) => 2002-03-07-05:00. fn:adjust-date-to-timezone(xs:date("2002-03-07-07:00")) => 2002-03-07-05:00. $arg is converted to the xs:dateTime "2002-03-07T00:00:00-07:00". This is adjusted to the implicit timezone, giving "2002-03-07T02:00:00-05:00". fn:adjust-date-to-timezone( xs:date("2002-03-07"), xs:dayTimeDuration("-PT10H")) => 2002-03-07-10:00. fn:adjust-date-to-timezone( xs:date("2002-03-07-07:00"), xs:dayTimeDuration("-PT10H")) => 2002-03-06-10:00. $arg is converted to the xs:dateTime "2002-03-07T00:00:00-07:00". This is adjusted to the given timezone, giving "2002-03-06T21:00:00-10:00". fn:adjust-date-to-timezone(xs:date("2002-03-07"), ()) => 2002-03-07. fn:adjust-date-to-timezone( xs:date("2002-03-07-07:00"), ()) => 2002-03-07.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.