XSL-T to convert ISO8601 date to RFC 822 date

This is a partial implementation of an XSL-T template to covert from an ISO8601 date to an RFC 822 date. It isn't exactly correct, but it can serve as a starting point if you really need such a thing. I'm just posting it in case it might be useful to someone. I was going to use it to generate an RSS 2.0 feed, but decided to abandon it and just use Dublin Core dates that are already in ISO8601 format. This depends on the use of the EXSLT date functions.

    <!-- Converts a date in ISO 8601 format into a date in RFC 822 format -->
    <xsl:template name="rfc822Date">
        <xsl:param name="isoDate"/>
        
        <xsl:value-of select="date:day-abbreviation($isoDate)"/>, <xsl:value-of select="date:day-in-month($isoDate)"/><xsl:text> </xsl:text>
        <xsl:value-of select="date:month-abbreviation($isoDate)"/><xsl:text> </xsl:text>      
        <xsl:value-of select="date:year($isoDate)"/><xsl:text> </xsl:text> 
        
        <!-- the timezone offset is currently hardcoded needs to be fixed -->
        <xsl:value-of select="date:hour-in-day($isoDate)"/>:<xsl:value-of select="date:minute-in-hour($isoDate)"/>:<xsl:value-of select="date:second-in-minute($isoDate)"/> -0700
    </xsl:template><p />

Posted by Kimbro Staken

Tuesday Aug 26, 2003 at 3:08 AM
Recommended Sites