Created
February 2, 2012 15:44
-
-
Save aliciaduffy/1724058 to your computer and use it in GitHub Desktop.
reformat pubdate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:template match="channel"> | |
<xsl:for-each select="item[position()<=1"> | |
<xsl:variable name="date"><xsl:value-of select="pubDate"/></xsl:variable> | |
<p class="podcastfile">Latest podcast: <a href="{link}"> | |
<xsl:call-template name="FormatDate3"><xsl:with-param name="date" select="substring-before($date, ' +')"/></xsl:call-template>: <strong><xsl:value-of select="title"/></strong></a></p> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="FormatDate3"> | |
<xsl:param name="date"/> | |
<xsl:variable name="day" select="substring-before(substring-after($date, ' '), ' ')"/> | |
<xsl:variable name="day2" select="concat(translate(substring($day,1,1), '0', ''), substring($day,2,1))"/> | |
<xsl:variable name="monthName" select="substring-before(substring-after(substring-after($date, ' '), ' '), ' ')"/> | |
<xsl:variable name="year" select="substring-before(substring-after(substring-after(substring-after($date, ' '), ' '), ' '), ' ')"/> | |
<xsl:variable name="month"> | |
<xsl:choose> | |
<xsl:when test="$monthName = 'Jan'">January</xsl:when> | |
<xsl:when test="$monthName = 'Feb'">February</xsl:when> | |
<xsl:when test="$monthName = 'Mar'">March</xsl:when> | |
<xsl:when test="$monthName = 'Apr'">April</xsl:when> | |
<xsl:when test="$monthName = 'May'">May</xsl:when> | |
<xsl:when test="$monthName = 'Jun'">June</xsl:when> | |
<xsl:when test="$monthName = 'Jul'">July</xsl:when> | |
<xsl:when test="$monthName = 'Aug'">August</xsl:when> | |
<xsl:when test="$monthName = 'Sep'">September</xsl:when> | |
<xsl:when test="$monthName = 'Oct'">October</xsl:when> | |
<xsl:when test="$monthName = 'Nov'">November</xsl:when> | |
<xsl:when test="$monthName = 'Dec'">December</xsl:when> | |
<xsl:otherwise/> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:value-of select="concat($month, ' ', $day2, ', ', $year)"/> | |
</xsl:template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment