XSLT transformation to RFC822 Date Format (RSS1 to RSS2)
September 29th, 2006
Because I never want to have to remember this again.
RSS1 allows a date format of ‘2006-09-23T12:30:00Z’
RSS2 wants it as ‘23 Sep 2006 12:30:00 EST’
<xsl:analyze-string select="###YOUR VALUE###" regex="(\d{{4}})-(\d{{2}})-(\d{{2}})T([\d:]*)Z”>
<xsl:matching-substring>
<xsl:value-of select=”regex-group(3)” />
<xsl:text> </xsl:text>
<xsl:variable name=”month” select=”number(regex-group(2))”/>
<xsl:choose>
<xsl:when test=”$month=1″>Jan</xsl:when>
<xsl:when test=”$month=2″>Feb</xsl:when>
<xsl:when test=”$month=3″>Mar</xsl:when>
<xsl:when test=”$month=4″>Apr</xsl:when>
<xsl:when test=”$month=5″>May</xsl:when>
<xsl:when test=”$month=6″>Jun</xsl:when>
<xsl:when test=”$month=7″>Jul</xsl:when>
<xsl:when test=”$month=8″>Sug</xsl:when>
<xsl:when test=”$month=9″>Sep</xsl:when>
<xsl:when test=”$month=10″>Oct</xsl:when>
<xsl:when test=”$month=11″>Nov</xsl:when>
<xsl:when test=”$month=12″>Dec</xsl:when>
</xsl:choose>
<xsl:value-of select=”concat(’ ‘ , regex-group(1), ‘ ‘,regex-group(4), ‘ EST’)”/>
</xsl:matching-substring>
</xsl:analyze-string>
Matt, this is my code. I had help, but IT IS MY CODE.
Update
Matt’s reply the next monday:
<xsl:value-of select="format-dateTime(###YOUR VALUE###, '[FNn], [D01] [MNn] [Y] [H01]:[m01]:[s01] [z]‘, ‘en’, (), ())” />
Notice the lack of quotes around ###YOUR VALUE### in this version.
-Sud.
Posted in Technical |