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 20th, 2006, 05:11 AM
Authorized User
 
Join Date: Jul 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT date transformation

Hello everyone,
          I would like to convert a local time to GMT time using XSLT,any ideas?
The time format I want to convert is the following:

2006-06-15T11:40

Thanks in advance.

Tomi

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

There are plenty of functions for this kind of operation in XPath 2.0. Append ":00", cast to an xs:dateTime value, then use the adjustDateTimeToTimezone function.

In 1.0 you might find something useful in the EXSLT date/time library at www.exslt.org.

If not, you can do it yourself: split the string into its components using substring(), convert to numbers, perform addition/subtraction as required, reconstitute the string.

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

Dear Mr Kay,
       Thanks for your quick response.I tried to convert it myself using substring but the problem is that I dont know the exact formula to make the time conversion(ie I dont know when to substract 1 hour or when to add one hour...).
       Regarding to the EXSLT or XPath functions I havent found one that makes the specific conversion from local-time to GMT time.

Thanks for the help.

Tomi


Quote:
quote:Originally posted by mhkay
 There are plenty of functions for this kind of operation in XPath 2.0. Append ":00", cast to an xs:dateTime value, then use the adjustDateTimeToTimezone function.

In 1.0 you might find something useful in the EXSLT date/time library at www.exslt.org.

If not, you can do it yourself: split the string into its components using substring(), convert to numbers, perform addition/subtraction as required, reconstitute the string.

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
help on xslt transformation li72 XSLT 2 March 4th, 2008 10:14 AM
Help on XSLT transformation li72 XSLT 2 February 22nd, 2008 12:33 PM
help with xslt transformation li72 XSLT 6 November 19th, 2007 01:51 PM
XSLT transformation yengzhai XSLT 1 April 21st, 2005 05:51 AM
XSLT transformation causes ^M reddygaru XSLT 2 December 16th, 2003 10:41 AM





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