Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 26th, 2006, 03:20 AM
Authorized User
 
Join Date: Jul 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default function adjust-dateTime-to-timezone

Hello everyone,
            I want to use this function to convert a local time(in this case Spain) to GMT/UTC time.My call to the function is the following:

<xsl:value-of select="adjust-dateTime-to-timezone(xs:dateTime($date))"/>

If for example date equals 2006-07-24T07:44:00 the function returns
2006-07-24T07:44:00+02:00.This is still my local time but with the difference from the GMT/UTC time(2 hours).

What I want is the GMT/UTC time(local - 2 hours)(ie 2006-07-24T05:44:00+02:00).

I know that I can simply substract 2 hours to the local time but I would have to ckeck too many things.


Is there anyway to do this?

Thank you very much for the help.


Tomi.



 
Old July 26th, 2006, 03:37 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

adjust--to-timezone() with no parameters, when the input is a time-without-timezone, says "treat this input time as representing a time in timezone IT", where IT is the implicit timezone taken from the evaluation context (which in practice means from the computer's system clock settings). I think you want to treat it as a time in timezone Z, which you can achieve using

adjust--to-timezone($in, xs:dayTimeDuration('PT0H'))

You can then convert this to timezone +02:00, or to IT, by a further call on the function:

adjust--to-timezone($temp, xs:dayTimeDuration('PT2H'))

or simply

adjust--to-timezone($temp)

where $temp is the result of the first call.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 26th, 2006, 05:30 AM
Authorized User
 
Join Date: Jul 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Mr Kay,
           Is there any way to obtain the current difference in hours between a local time and GMT time?(ie asking the computer's system clock).

This difference is not always the same because of the daylight savings time.

In spanish case:
Standard Time = GMT+1
Summer Time = GMT+2

I really appreciate your help.

Tomi

Quote:
quote:Originally posted by mhkay
 adjust--to-timezone() with no parameters, when the input is a time-without-timezone, says "treat this input time as representing a time in timezone IT", where IT is the implicit timezone taken from the evaluation context (which in practice means from the computer's system clock settings). I think you want to treat it as a time in timezone Z, which you can achieve using

adjust--to-timezone($in, xs:dayTimeDuration('PT0H'))

You can then convert this to timezone +02:00, or to IT, by a further call on the function:

adjust--to-timezone($temp, xs:dayTimeDuration('PT2H'))

or simply

adjust--to-timezone($temp)

where $temp is the result of the first call.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 26th, 2006, 11:51 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The implicit-timezone() function gives you this difference. For example, I would expect that in your environment implicit-timezone returns the duration PT2H. If you want to convert this to an integer number of hours, divide by xs:dayTimeDuration('PT1H').

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find the local timezone Tomi XSLT 0 July 26th, 2006 06:14 AM
timezone conversion swati_joshi ASP.NET 1.0 and 1.1 Professional 0 June 2nd, 2006 05:21 AM
TimeZone Issue everest ASP.NET 1.0 and 1.1 Professional 1 November 3rd, 2005 01:54 AM
datetime function Adam H-W Classic ASP Basics 5 July 23rd, 2005 02:24 AM
[ReportingService] DateTime function errors WindyZhu SQL Server 2000 2 June 17th, 2004 01:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.