fn.adjustDateTimeToTimezone( arg as Date?, [timezone as xs.dayTimeDuration?] ) as Date?
Adjusts an xs:dateTime value to a specific timezone, or to no timezone at all. If $timezone is the empty sequence, returns an xs:dateTime without a timezone. Otherwise, returns an xs:dateTime with a timezone.
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 the result is an xs:dateTime value with a timezone component of $timezone that is equal to $arg.
Parameters | |
---|---|
arg | The dateTime to adjust to the new timezone. |
timezone | The new timezone for the dateTime. |
Assume the dynamic context provides an implicit timezone of -05:00 (-PT5H0M). fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T10:00:00")) => 2002-03-07T10:00:00-05:00 fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T10:00:00-07:00")) => 2002-03-07T12:00:00-05:00 fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T10:00:00"), xs.dayTimeDuration("-PT10H")) => 2002-03-07T10:00:00-10:00 fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T10:00:00-07:00"), xs.dayTimeDuration("-PT10H")) => 2002-03-07T07:00:00-10:00 fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T10:00:00-07:00"), xs.dayTimeDuration("PT10H")) => 2002-03-08T03:00:00+10:00 fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T00:00:00+01:00"), xs.dayTimeDuration("-PT8H")) => 2002-03-06T15:00:00-08:00 fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T10:00:00"), ()) => 2002-03-07T10:00:00 fn.adjustDateTimeToTimezone( xs.dateTime("2002-03-07T10:00:00-07:00"), ()) => 2002-03-07T10:00:00
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.