Here is a XSLT 2.0 solution tested with Saxon 8.4
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xyz="http://utc"
version="2.0">
<xsl:output method="text" />
<xsl:template match="/">
UTC time(hh:mm:ss) - <xsl:value-of
select="xyz:UtcTime(xs:string(current-time()))" />
</xsl:template>
<xsl:function name="xyz:UtcTime">
<xsl:param name="curr-time" as="xs:string"/>
<xsl:choose>
<xsl:when test="contains($curr-time,'+')">
<xsl:variable name="local-time"
select="substring-before($curr-time,'+')" />
<xsl:variable name="time-zone"
select="substring-after($curr-time,'+')" />
<xsl:variable name="x" select="substring-before($local-time,':')" />
<xsl:variable name="y"
select="substring-before(substring-after($local-time,':'),':')" />
<xsl:variable name="z"
select="substring-after(substring-after($local-time,':'),':')" />
<xsl:variable name="sec1" select="(xs:integer($x) * 60 * 60) +
(xs:integer($y) * 60) + xs:float($z)" />
<xsl:variable name="u" select="substring-before($time-zone,':')" />
<xsl:variable name="v" select="substring-after($time-zone,':')" />
<xsl:variable name="sec2" select="(xs:integer($u) * 60 * 60) +
(xs:integer($v) * 60)" />
<xsl:variable name="sec3" select="$sec1 - $sec2" />
<xsl:value-of select="floor(($sec3 div 60) div 60)"
/>:<xsl:value-of select="floor(($sec3 div 60) mod 60)"
/>:<xsl:value-of select="$sec3 - ((floor(($sec3 div 60) div 60) * 60 *
60) + (floor(($sec3 div 60) mod 60) * 60))" />
</xsl:when>
<xsl:when test="contains($curr-time,'-')">
<xsl:variable name="local-time"
select="substring-before($curr-time,'-')" />
<xsl:variable name="time-zone"
select="substring-after($curr-time,'-')" />
<xsl:variable name="x" select="substring-before($local-time,':')" />
<xsl:variable name="y"
select="substring-before(substring-after($local-time,':'),':')" />
<xsl:variable name="z"
select="substring-after(substring-after($local-time,':'),':')" />
<xsl:variable name="sec1" select="(xs:integer($x) * 60 * 60) +
(xs:integer($y) * 60) + xs:float($z)" />
<xsl:variable name="u" select="substring-before($time-zone,':')" />
<xsl:variable name="v" select="substring-after($time-zone,':')" />
<xsl:variable name="sec2" select="(xs:integer($u) * 60 * 60) +
(xs:integer($v) * 60)" />
<xsl:variable name="sec3" select="$sec1 + $sec2" />
<xsl:value-of select="floor(($sec3 div 60) div 60)"
/>:<xsl:value-of select="floor(($sec3 div 60) mod 60)"
/>:<xsl:value-of select="$sec3 - ((floor(($sec3 div 60) div 60) * 60 *
60) + (floor(($sec3 div 60) mod 60) * 60))" />
</xsl:when>
</xsl:choose>
</xsl:function>
</xsl:stylesheet>
Regards,
Mukul
On 8/23/05, Meena Nanjundeswar <meenasargur(_at_)gmail(_dot_)com> wrote:
Hi List:
I need to display time in UTC on my stylesheet. Any suggestions?
Thank you in advance
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--