Use more accurate names for the date conversion functions
authorAntonio Ospite <ao2@ao2.it>
Tue, 17 May 2016 21:28:45 +0000 (23:28 +0200)
committerAntonio Ospite <ao2@ao2.it>
Fri, 20 May 2016 09:02:35 +0000 (11:02 +0200)
The new names are epochToRssDate and strToRssDate.

Don't refer to gmdate() in the function names, this is just an
implementation detail which should not have leaked into the external
interface, instead mention RssDate in the function names to communicate
something about the output they produce.

Also, while at it, user the DATE_RSS format when calling gmdate().

rss_converter_dilbert.com.xsl
rss_converter_facebook.com.xsl
rss_converter_howtoons.com.xsl
rss_converter_instagram.com.xsl
rss_converter_pump.io.xsl
rss_converter_twitter.com.xsl
tweeper.php

index b7f9fbf..ce7075f 100644 (file)
@@ -67,7 +67,7 @@
                 <xsl:value-of select="$item-permalink"/>
             </guid>
             <pubDate>
-                <xsl:value-of select="php:functionString('Tweeper::strToGmdate', normalize-space(.//date))"/>
+                <xsl:value-of select="php:functionString('Tweeper::strToRssDate', normalize-space(.//date))"/>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
index ecbd18c..89cc67d 100644 (file)
@@ -85,7 +85,7 @@
             </guid>
             <pubDate>
                 <xsl:variable name="timestamp" select=".//abbr[@data-shorten]/@data-utime"/>
-                <xsl:value-of select="php:functionString('Tweeper::epochToGmdate', number($timestamp))"/>
+                <xsl:value-of select="php:functionString('Tweeper::epochToRssDate', number($timestamp))"/>
             </pubDate>
             <description>
 
index 7c34729..403b9ac 100644 (file)
@@ -57,7 +57,7 @@
                 <xsl:variable name="day" select="substring($date, 4, 2)"/>
                 <xsl:variable name="year" select="substring($date, 7, 2)"/>
                 <xsl:variable name="iso-date" select="concat('20', $year, '-', $month, '-', $day)"/>
-                <xsl:value-of select="php:functionString('Tweeper::strToGmdate', $iso-date)"/>
+                <xsl:value-of select="php:functionString('Tweeper::strToRssDate', $iso-date)"/>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
index 9122315..5a64a57 100644 (file)
@@ -79,7 +79,7 @@
             </guid>
             <pubDate>
                 <xsl:variable name="timestamp" select="./date"/>
-                <xsl:value-of select="php:functionString('Tweeper::epochToGmdate', number($timestamp))"/>
+                <xsl:value-of select="php:functionString('Tweeper::epochToRssDate', number($timestamp))"/>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
index 95abf3e..c505a50 100644 (file)
@@ -46,7 +46,7 @@
                 <xsl:value-of select="$item-permalink"/>
             </guid>
             <pubDate>
-                <xsl:value-of select="php:functionString('Tweeper::strToGmdate', .//abbr[@class='easydate']/@title)"/>
+                <xsl:value-of select="php:functionString('Tweeper::strToRssDate', .//abbr[@class='easydate']/@title)"/>
             </pubDate>
             <description>
                 <xsl:value-of select="concat($user-name, ': ')"/>
index 59c29bb..0701d5c 100644 (file)
@@ -54,7 +54,7 @@
             </guid>
             <pubDate>
                 <xsl:variable name="timestamp" select=".//span[contains(@class, 'js-short-timestamp')]/@data-time"/>
-                <xsl:value-of select="php:functionString('Tweeper::epochToGmdate', number($timestamp))"/>
+                <xsl:value-of select="php:functionString('Tweeper::epochToRssDate', number($timestamp))"/>
             </pubDate>
             <description>
                 <xsl:value-of select="concat($user-name, ': ')"/>
index fdf6e5c..3e250b7 100644 (file)
@@ -44,24 +44,24 @@ class Tweeper {
   /**
    * Convert numeric Epoch to the date format expected in a RSS document.
    */
-  public static function epochToGmdate($timestamp) {
+  public static function epochToRssDate($timestamp) {
     if (!is_numeric($timestamp) || is_nan($timestamp)) {
       $timestamp = 0;
     }
 
-    return gmdate('D, d M Y H:i:s', $timestamp) . ' GMT';
+    return gmdate(DATE_RSS, $timestamp);
   }
 
   /**
    * Convert generic date string to the date format expected in a RSS document.
    */
-  public static function strToGmdate($date) {
+  public static function strToRssDate($date) {
     $timestamp = strtotime($date);
     if (FALSE === $timestamp) {
       $timestamp = 0;
     }
 
-    return Tweeper::epochToGmdate($timestamp);
+    return Tweeper::epochToRssDate($timestamp);
   }
 
   /**