Functions That Adjust Time Zones

There's also a set of functions designed to adjust the timezone of xs:dateTime , xs:date , and xs:time values:

  • fn:adjust-dateTime-to-timezone adjusts an xs:dateTime value to a specific timezone, or to no timezone at all.

  • fn:adjust-date-to-timezone adjusts an xs:date value to a specific timezone, or to no timezone at all.

  • fn:adjust-time-to-timezone adjusts an xs:time value to a specific timezone, or to no timezone at all.

The fn:adjust-dateTime-to-timezone Function

This function adjusts timezones for xs:dateTime values:

 
 fn:adjust-dateTime-to-timezone(  $srcval  as xs:dateTime?) as xs:dateTime? fn:adjust-dateTime-to-timezone(  $srcval  as xs:dateTime?,  $timezone  as xdt:dayTimeDuration?) as xs:dateTime? 

When you call this function, it returns an xs:dateTime value with a new timezone as specified in $timezone . If you don't specify $timezone , $timezone is set to the value of the implicit timezone in the evaluation context. And if $srcval has a timezone component but $timezone is an empty sequence, $srcval is returned without a timezone component.

Here's an example:

 
 fn:adjust-dateTime-to-timezone(xs:dateTime("2004-07-09T19:48:00"),     xdt:dayTimeDuration("-PT02H")) 

This example returns an xs:dateTime with the time "2004-07-09T19:48:00-02:00" .

The fn:adjust-date-to-timezone Function

The fn:adjust-date-to-timezone function adjusts the timezone in xs:date values:

 
 fn:adjust-date-to-timezone($srcval as xs:date?) as xs:date? fn:adjust-date-to-timezone($srcval as xs:date?, $timezone as xdt:dayTimeDuration?) as xs:date? 

This function returns an xs:date value with the given timezone, or with no timezone at all. If $srcval does not have a timezone and $timezone is not the empty sequence, the result returned is $srcval with $timezone as the timezone component. If $srcval does have a timezone component and $timezone is the empty sequence, the result is $srcval without a timezone component. On the other hand, if you don't specify $timezone , $timezone is set to the value of the implicit timezone in the evaluation context.

For example, this expression returns an xs:date value with the date "2004-03-01-03:00":

 
 fn:adjust-date-to-timezone(xs:date("2004-03-01"), xdt:dayTimeDuration("-PT03H")) 

The fn:adjust-time-to-timezone Function

This is the last of the timezone-adjusting functions, and you use it on xs:time values:

 
 fn:adjust-time-to-timezone($srcval as xs:time?) as xs:dateTime? fn:adjust-time-to-timezone( $srcval  as xs:time?, $timezone  as xdt:dayTimeDuration?) as xs:time? 

This function returns an xs:time value with the given timezone, or with no timezone at all. If $srcval does not have a timezone and you pass a $timezone value, the result is $srcval with the timezone $timezone . If $srcval has a timezone component and $timezone is an empty sequence, you get $srcval back without a timezone component. As with the other timezone-adjusting functions, if you don't specify $timezone , $timezone is set to the value of the implicit timezone in the evaluation context.

For instance, this example returns an xs:time value set to "19:48:00-05:00":

 
 fn:adjust-time-to-timezone(xs:time("19:48:00"), xdt:dayTimeDuration("-PT05H")) 


XPath. Navigating XML with XPath 1.0 and 2.0 Kick Start
XPath Kick Start: Navigating XML with XPath 1.0 and 2.0
ISBN: 0672324113
EAN: 2147483647
Year: 2002
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net