Subject: RE: RE: RE: RE: [xsl] GMT to BST converter From: "tom tom" <tomxsllist@xxxxxxxxxxx> Date: Mon, 18 Apr 2005 11:05:11 +0100 |
From: cknell@xxxxxxxxxx Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: RE: RE: RE: [xsl] GMT to BST converter Date: Fri, 15 Apr 2005 15:54:25 -0400
Thanks for pointing out my error. That makes sense. Here is the template I constructed. It has been lightly tested (most edge cases and the no-question cases). It has not been optimized. I image that it could be done more compactly and with fewer convenience variables. Although eliminating the convenience variables would make it much trickier to grasp, it would make the template more compact.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:param name="start-date" select="'23'" /> <xsl:param name="end-date" select="'28'" />
<xsl:template match="/"> <xsl:apply-templates /> </xsl:template>
<xsl:template match="Date">
<xsl:variable name="DOW" select="substring-before(., ', ')" />
<xsl:variable name="dm" select="substring-before(substring-after(.,', '),', ')" />
<xsl:variable name="M" select="substring-after($dm,' ')" />
<xsl:variable name="D" select="substring-before($dm,' ')" />
<xsl:variable name="h" select="substring-before(substring-after(substring-after(substring-after(.,$dm), ', '), ', '), ' GMT')" />
<xsl:variable name="y" select="substring-after(substring-before(., $h),$dm)" />
<xsl:variable name="Y" select="substring-before(substring-after($y, ', '), ',')" />
<xsl:variable name="shr" select="concat(number(substring-before($h, ':')) + 1, ':', substring-after($h, ':'))" />
<xsl:choose>
<xsl:when test="$M='October'" >
<xsl:choose>
<xsl:when test="$DOW = 'Sunday' and $D > 24">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) < 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Monday' and $D > 25">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) < 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Tuesday' and $D > 26">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) < 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Wednesday' and $D > 27">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) < 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Thursday' and $D > 28">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) < 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Friday' and $D > 29">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) < 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Saturday' and $D > 30">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) < 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$M='March'" >
<xsl:choose>
<xsl:when test="$DOW = 'Sunday' and $D > 24">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) >= 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Monday' and $D > 25">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) >= 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Tuesday' and $D > 26">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) >= 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Wednesday' and $D > 27">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) >= 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Thursday' and $D > 28">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) >= 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Friday' and $D > 29">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) >= 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$DOW = 'Saturday' and $D > 30">
<xsl:choose>
<xsl:when test="number(substring-before($h, ':')) >= 1">
<Date><xsl:value-of select="concat($DOW, ', ', $D, ' ', $M, ', ',$Y, ', ', $shr, ' BST')" /></Date>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> -- Charles Knell cknell@xxxxxxxxxx - email
-----Original Message----- From: Michael Kay <mike@xxxxxxxxxxxx> Sent: Fri, 15 Apr 2005 19:36:53 +0100 To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: RE: RE: RE: [xsl] GMT to BST converter
> > http://webexhibits.org/daylightsaving/b.html > > > > All the references I've found on the web (including the BBC) > > say that it (BST) begins and ends at 0100 hours. In the U.S. > > the time is 0200 so the issue of "Is it today or yesterday?" > > doesn't come up. > > > > > When the clock is turned back at the end of Summer Time, does > > > the time then become 00:00:01 of the same day or is it set > > > back to midnight of the previous day? > >
The reference above says that BST ends at 01:00 GMT, i.e. at 02:00 BST.
Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: RE: RE: RE: [xsl] GMT to BST co, cknell | Thread | RE: RE: RE: RE: RE: [xsl] GMT to BS, cknell |
RE: [xsl] xsl sort: using element a, Michael Kay | Date | [xsl] grouping, sorting, splitting, beowulf |
Month |