Loading TOC...

MarkLogic 9 Product Documentation
fn:adjust-time-to-timezone

fn:adjust-time-to-timezone(
   $arg as xs:time?,
   [$timezone as xs:dayTimeDuration?]
) as xs:time?

Summary

Adjusts an xs:time value to a specific timezone, or to no timezone at all. If $timezone is the empty sequence, returns an xs:time without a timezone. Otherwise, returns an xs:time 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:

Let $srcdt be an xs:dateTime value, with an arbitrary date for the date component and time and timezone components that are the same as the time 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 time value that has time and timezone components that are the same as the time and timezone components of $r.

Parameters
arg The time to adjust to the new timezone.
timezone The new timezone for the date.

Example

Assume the dynamic context provides an implicit timezone
of -05:00 (-PT5H0M).

fn:adjust-time-to-timezone(xs:time("10:00:00"))
=> 10:00:00-05:00

fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"))
=> 12:00:00-05:00

fn:adjust-time-to-timezone(xs:time("10:00:00"), 
  xs:dayTimeDuration("-PT10H"))
=> 10:00:00-10:00

fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"), 
  xs:dayTimeDuration("-PT10H"))
=> 07:00:00-10:00

fn:adjust-time-to-timezone(xs:time("10:00:00"), ())
=> 10:00:00

fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"), ())
=> 10:00:00

fn:adjust-time-to-timezone(
    xs:time("10:00:00-07:00"),
    xs:dayTimeDuration("PT10H"))
=> 03:00:00+10:00

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.