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-time-to-timezone
Category:
Date functions – timezone
Origin:
XPath 2.0
Return value:
A time indication xs:time.
Call/Arguments:
fn:adjust-time-to-timezone($time?, $timezone?)
$time:
Optional. A time value of xs:time type. 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 implicit timezone indication in the evaluation context is used. If the empty sequence is passed on as second argument, an existing timezone indication from the time value is removed.
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 adjusts a time value xs:time to a timezone indication which is passed on as second argument or which is implicit from the context. The original timezone factor is taken into account for the result (see example 6).
Example 1 - without passing on a timezone correction:
xs:time("10:00:00")
)
Results in: 10:00:00-05:00.
For the purpose of this example, an implicit timezone indication of -5:00 was assumed, accordingly -PT5H0M. Since no second argument has been passed on, the implicit timezone indication is connected with the time value and outputted. The time indication itself is not changed.
Example 2 - without passing on a timezone correction:
xs:time("10:00:00-07:00")
)
Results in: 12:00:00-05:00.
For the purpose of this example, an implicit timezone indication of -5:00 was assumed, accordingly -PT5H0M. If a timestamp value is passed on with a timezone indication, but without a timezone correction, the timezone indication is rejected and replaced by the implicit timezone indication. The time is adjusted by subtracting the original timezone factor and adding the new one. In this case, the result is 12:00:00 out of 10:00:00 – (-07:00) + (-05:00).
Example 3 - with passing on a timezone correction:
xs:time("10:00:00"),
xs:dayTimeDuration("-PT10H")
)
Results in: 10:00:00-10:00.
If a correction factor is passed on as second argument in the form of a timezone indication, this factor is connected to 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:
xs:time("10:00:00-07:00"),
xs:dayTimeDuration("-PT10H")
)
Results in: 07:00:00-10:00.
If the value already has a timezone indication in the form of a factor, it will be replaced by the timezone factor passed on. A possible existing implicit timezone value of the evaluation context is not taken into account. The time indication is adjusted analogously to example 2.
Example 5 - with passing on an empty sequence:
xs:time("10:00:00-07:00"),
()
)
Results in: 10:00:00.
If the time indication has a timezone indication and an empty sequence is passed on to the function as second argument, the timezone indication is removed from the time indication. A possible existing implicit timezone value of the evaluation context is not taken into account.
Example 6 - with overflow:
xs:time("10:00:00-07:00"),
xs:dayTimeDuration("PT10H")
)
Results in: 03:00:00+10:00.
If the correction of the time indication results in a value greater than 24 for the hours indication when including both timezone corrections, the time indication is adjusted to the result value of minus 24 hours. In this example, the time indication results in: (10:00:00 – (-07:00)) + 10:00 equals 27 hours, which is converted into 03:00:00.
Function definition:
XPath 1.0:
The function is not available.
XPath 2.0:
fn:adjust-time-to-timezone($arg as xs:time?)
as xs:time?
fn:adjust-time-to-timezone($arg as xs:time?,
$timezone as xs:dayTimeDuration?)
as xs:time?
<< 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