-
-
Save sirlancelot/92057 to your computer and use it in GitHub Desktop.
made template match 'pubDate' so it can be called by 'apply-templates', removed redundant substring()s
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
<?xml version="1.0" encoding="UTF-8" ?> | |
<!-- | |
XSL Utility for Symphony 2 | |
Convert RSS feed date format to Symphony date format | |
Convert RFC 2822 timestamp format to ISO date format minus the time info (Symphony CMS date format) | |
RFC 2822 format: Sun, 7 Jan 2007 12:00:00 GMT | |
ISO 8601 format (minus the time info): 2007-01-07 | |
--> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:template match="pubDate" name="format-from-rfc-to-iso"> | |
<xsl:param name="rfc-date" select="." /> | |
<xsl:param name="day-with-zero" select="format-number(substring($rfc-date,6,2),'00')" /> | |
<xsl:param name="month-with-zero"> | |
<xsl:if test="contains($rfc-date,'Jan')">01</xsl:if> | |
<xsl:if test="contains($rfc-date,'Feb')">02</xsl:if> | |
<xsl:if test="contains($rfc-date,'Mar')">03</xsl:if> | |
<xsl:if test="contains($rfc-date,'Apr')">04</xsl:if> | |
<xsl:if test="contains($rfc-date,'May')">05</xsl:if> | |
<xsl:if test="contains($rfc-date,'Jun')">06</xsl:if> | |
<xsl:if test="contains($rfc-date,'Jul')">07</xsl:if> | |
<xsl:if test="contains($rfc-date,'Aug')">08</xsl:if> | |
<xsl:if test="contains($rfc-date,'Sep')">09</xsl:if> | |
<xsl:if test="contains($rfc-date,'Oct')">10</xsl:if> | |
<xsl:if test="contains($rfc-date,'Nov')">11</xsl:if> | |
<xsl:if test="contains($rfc-date,'Dec')">12</xsl:if> | |
</xsl:param> | |
<xsl:param name="year-full" select="format-number(substring(pubDate,13,4),'####')" /> | |
<xsl:value-of select="concat($year-full,'-',$month-with-zero,'-',$day-with-zero)" /> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment