Created
May 10, 2012 14:42
-
-
Save xpathr/2653556 to your computer and use it in GitHub Desktop.
RFC date to ISO date by bzerangue
This file contains hidden or 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" ?> | |
| <!-- | |
| Name: RSS feed date format to Symphony date format | |
| Version: 1.0 | |
| Author: Brian Zerangue <brian.zerangue@gmail.com> | |
| URL: http://symphony21.com/downloads/xslt/file/20457/ | |
| Description: | |
| 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 name="format-from-rfc-to-iso"> | |
| <xsl:param name="rfc-date"/> | |
| <xsl:param name="day-with-zero" select="format-number(substring(substring($rfc-date,6,11),1,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(substring($rfc-date,6,11),7,5),'####')"/> | |
| <xsl:param name="rfc-date-to-iso" select="concat($year-full,'-',$month-with-zero,'-',$day-with-zero)"/> | |
| <xsl:value-of select="$rfc-date-to-iso"/> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment