XSLT and XPath function reference in alphabetical order

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

fn:adjust-date-to-timezone

Category:

Date functions – timezone

Origin:

XPath 2.0

Return value:

A date value xs:date.

Call/Arguments:

fn:adjust-date-to-timezone($date?, $timezone?)

$date:

Optional. A date value xs:date. If no value is passed on, the function returns an empty sequence.

$timezone:

Optional. The second argument is a timezone indication of xs:dayTimeDuration type. If the argument is omitted, the timezone indication being implicit in the evaluation context is used. If the empty sequence is passed on as the second argument, an existing timezone indication is removed from the date value passed on as first argument; thus, the date value passed on is localised (localised value).

The timezone indication must not fall below a value of -PT14H and must not exceed a value of PT14H. Otherwise the error »Invalid timezone value« (err:FODT0003) will be reported.

Purpose of use:

The function connects a date value xs:date with a timezone indication which is passed on as second argument or which is implicit from the context.

Example 1 - without passing on a timezone correction:

fn:adjust-date-to-timezone(

xs:date("2007-07-07")

)

Results in: 2007-07-07-05:00.

For the purpose of this example, an implicit timezone indication of -5:00 is assumed, accordingly - PT5H0M. Since no second argument has been passed on, the implicit timezone indication is connected with the date value and outputted.

Example 2 - without passing on a timezone correction:

fn:adjust-date-to-timezone(

xs:date("2007-07-07-03:00")

)

Results in: 2007-07-07-05:00.

For the purpose of this example, an implicit timezone indication of -5:00 is assumed, accordingly - PT5H0M. The original timezone indication was -3:00. If a date value is passed on with a timezone indication but without a timezone correction, the timezone indication is rejected and replaced by an implicit timezone indication.

Example 3 - with passing on a timezone correction:

fn:adjust-date-to-timezone(

xs:date("2007-07-07"),

xs:dayTimeDuration("-PT10H")

)

Results in: 2007-07-07-10:00.

If a correction factor is passed on as second argument in the form of a timezone indication, this factor is connected with the result. A possible existing implicit timezone value of the evaluation context is not taken into account.

Example 4 - with passing on a timezone correction:

fn:adjust-date-to-timezone(

xs:date("2007-07-07-03:00"),

xs:dayTimeDuration("-PT10H")

)

Results in: 2007-07-07-10:00.

If the date already has a timezone indication in the form of a factor, this factor is replaced by the timezone factor passed on. A possible existing implicit timezone value of the evaluation context is not taken into account.

Example 5 - with passing on an empty sequence:

fn:adjust-date-to-timezone(

xs:date("2007-07-07-03:00"),

()

)

Results in: 2007-07-07.

If the date has a timezone indication and an empty sequence is passed on to the function as second argument, the timezone indication is removed from the date. A possible existing implicit timezone value of the evaluation context is not taken into account.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:adjust-date-to-timezone($arg as xs:date?)

as xs:date?

fn:adjust-date-to-timezone($arg as xs:date?,

$timezone as xs:dayTimeDuration?)

as xs:date?

   

<< back next >>

 

 

 


Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.


Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany