From 76afa982386da83e9542278ad3ea736d2fd486ff Mon Sep 17 00:00:00 2001
From: Antonio Ospite <ao2@ao2.it>
Date: Tue, 17 May 2016 23:28:45 +0200
Subject: [PATCH] Use more accurate names for the date conversion functions

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   | 2 +-
 rss_converter_facebook.com.xsl  | 2 +-
 rss_converter_howtoons.com.xsl  | 2 +-
 rss_converter_instagram.com.xsl | 2 +-
 rss_converter_pump.io.xsl       | 2 +-
 rss_converter_twitter.com.xsl   | 2 +-
 tweeper.php                     | 8 ++++----
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/rss_converter_dilbert.com.xsl b/rss_converter_dilbert.com.xsl
index b7f9fbf..ce7075f 100644
--- a/rss_converter_dilbert.com.xsl
+++ b/rss_converter_dilbert.com.xsl
@@ -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>
diff --git a/rss_converter_facebook.com.xsl b/rss_converter_facebook.com.xsl
index ecbd18c..89cc67d 100644
--- a/rss_converter_facebook.com.xsl
+++ b/rss_converter_facebook.com.xsl
@@ -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>
 
diff --git a/rss_converter_howtoons.com.xsl b/rss_converter_howtoons.com.xsl
index 7c34729..403b9ac 100644
--- a/rss_converter_howtoons.com.xsl
+++ b/rss_converter_howtoons.com.xsl
@@ -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>
diff --git a/rss_converter_instagram.com.xsl b/rss_converter_instagram.com.xsl
index 9122315..5a64a57 100644
--- a/rss_converter_instagram.com.xsl
+++ b/rss_converter_instagram.com.xsl
@@ -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>
diff --git a/rss_converter_pump.io.xsl b/rss_converter_pump.io.xsl
index 95abf3e..c505a50 100644
--- a/rss_converter_pump.io.xsl
+++ b/rss_converter_pump.io.xsl
@@ -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, ': ')"/>
diff --git a/rss_converter_twitter.com.xsl b/rss_converter_twitter.com.xsl
index 59c29bb..0701d5c 100644
--- a/rss_converter_twitter.com.xsl
+++ b/rss_converter_twitter.com.xsl
@@ -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, ': ')"/>
diff --git a/tweeper.php b/tweeper.php
index fdf6e5c..3e250b7 100644
--- a/tweeper.php
+++ b/tweeper.php
@@ -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);
   }
 
   /**
-- 
2.1.4