[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: calculate UTC
At 2012-06-24 17:35 +0100, henry human wrote:
thanks, I need only the difference and your script bello helps: Then I've already done the heavy lifting and all you need to do is format it by converting it to a time. Durations cannot be formatted directly, so I added the value of the timezone duration to midnight. You may want to deal with negative values if that is important to you. I hope the code below helps. . . . . . . . Ken ~/t/ftemp $ cat henry2.xml <?xml version="1.0" encoding="UTF-8"?> <STSF> <DTE>2012-06-14</DTE> <TME>06:20:00.0Z</TME> </STSF> ~/t/ftemp $ xslt2 henry2.xml henry2.xsl <?xml version="1.0" encoding="UTF-8"?> Local time zone: -PT3H Time zone difference: PT3H Formatted time zone difference: 03:00 File time in local time: 2012-06-14T03:20:00-03:00 ~/t/ftemp $ cat henry2.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="STSF"> Local time zone: <xsl:value-of select="implicit-timezone()"/> Time zone difference: <xsl:value-of select="timezone-from-dateTime(xsd:dateTime(concat(DTE,'T',TME))) - implicit-timezone()"/> Formatted time zone difference: <xsl:value-of select="format-time( xsd:time('00:00:00')+ timezone-from-dateTime(xsd:dateTime(concat(DTE,'T',TME))) - implicit-timezone(), '[H01]:[m01]')"/> File time in local time: <xsl:value-of select="adjust-dateTime-to-timezone( xsd:dateTime(concat(DTE,'T',TME)), implicit-timezone())"/> <xsl:text>
</xsl:text> </xsl:template> </xsl:stylesheet> ~/t/ftemp $
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|