<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.adjustDateToTimezone.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.adjustDateToTimezone</api:function-name><api:suggest>fn.adjustdatetotimezone</api:suggest><api:suggest>fn</api:suggest><api:suggest>adjustdatetotimezone</api:suggest><api:function-link mode="xquery" fullname="fn:adjust-date-to-timezone">/apidoc/8.0/fn:adjust-date-to-timezone.xml</api:function-link><api:function mode="javascript" name="adjustDateToTimezone" type="builtin" lib="fn" category="DurationDateTimeBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.adjustDateToTimezone"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $timezone is not specified, then $timezone is the value of the implicit
timezone in the dynamic context.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is the empty sequence, then the result is the empty sequence.
</p><p xmlns="http://www.w3.org/1999/xhtml">
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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg does not have a timezone component and $timezone is the empty
sequence, then the result is $arg.
</p><p xmlns="http://www.w3.org/1999/xhtml"> 
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.
</p><p xmlns="http://www.w3.org/1999/xhtml"> 
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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg has a timezone component and $timezone is not the empty sequence, then:
</p><p xmlns="http://www.w3.org/1999/xhtml">
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. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
Let $r be the result of evaluating fn:adjust-dateTime-to-timezone($srcdt,
$timezone)
</p><p xmlns="http://www.w3.org/1999/xhtml">
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.
</p>
</api:summary><api:params><api:param name="arg" type="xs:date?"><api:param-description>
The date to adjust to the new timezone.
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>Date?</api:param-type></api:param><api:param name="timezone" type="xs:dayTimeDuration?" optional="true"><api:param-description>
The new timezone for the date.
  </api:param-description><api:param-name>timezone</api:param-name><api:param-type>xs.dayTimeDuration?</api:param-type></api:param></api:params><api:return>Date?</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
Assume the dynamic context provides an implicit timezone
of -05:00 (-PT5H0M).

fn.adjustDateToTimezone(xs.date("2002-03-07"))
=&gt; 2002-03-07-05:00.

fn.adjustDateToTimezone(xs.date("2002-03-07-07:00"))
=&gt; 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.adjustDateToTimezone(
    xs.date("2002-03-07"), 
    xs.dayTimeDuration("-PT10H"))
=&gt; 2002-03-07-10:00.

fn.adjustDateToTimezone(
    xs.date("2002-03-07-07:00"), 
    xs.dayTimeDuration("-PT10H"))
=&gt; 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.adjustDateToTimezone(xs.date("2002-03-07"), ())
=&gt; 2002-03-07.

fn.adjustDateToTimezone(
    xs.date("2002-03-07-07:00"), ())
=&gt; 2002-03-07.
</pre>
</api:example></api:function></api:function-page>