Index: templates/rss/rss20.template
===================================================================
--- templates/rss/rss20.template (revision 2369)
+++ templates/rss/rss20.template (working copy)
@@ -9,7 +9,7 @@
{$blog->getBlog()|escape}
{$url->blogLink()}
{$blog->getAbout()|escape}
- {$locale->formatDate($now, "%a, %d %b %Y %H:%M:%S")}
+ {$locale->formatDateGMT($now, "%a, %d %b %Y %H:%M:%S GMT")}
http://www.plogworld.net
{foreach from=$posts item=post}
-
@@ -26,7 +26,7 @@
{$category->getName()|escape}
{/foreach}
{assign var="postDate" value=$post->getDateObject()}
- {$locale->formatDate($postDate, "%a, %d %b %Y %H:%M:%S")}
+ {$locale->formatDateGMT($postDate, "%a, %d %b %Y %H:%M:%S GMT")}
{$blog->getBlog()|escape}
{foreach from=$post->getArticleResources() item=resource}
{** please uncomment the line below if you'd like to server everything but images, instead of
Index: class/locale/locale.class.php
===================================================================
--- class/locale/locale.class.php (revision 2369)
+++ class/locale/locale.class.php (working copy)
@@ -421,9 +421,9 @@
*
* @return A string with the ordinal representation of the day.
*/
- function getDayOrdinal( $t )
+ function getDateOrdinal( $date )
{
- $dayOrdinal = $t->getDay();
+ $dayOrdinal = $date;
$last_digit = substr( $dayOrdinal, -1 );
if( $dayOrdinal < 10 )
$dayOrdinal = $last_digit;
@@ -437,12 +437,19 @@
$dayOrdinal .= "."; break;
case "en":
default:
- $dayOrdinal = $this->_getOrdinal( $t->getDay()); break;
+ $dayOrdinal = $this->_getOrdinal( $date); break;
}
return $dayOrdinal;
- }
+ }
+ function getDayOrdinal( $t )
+ {
+ $dayOrdinal = $t->getDay();
+ return $this->getDateOrdinal( dayOrdinal );
+ }
+
+
/**
* Formats the date of a Timestamp object according to the given format:
*
@@ -489,7 +496,7 @@
$format = $this->_dateFormat;
// now we can continue normally
- $values["%a"] = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($weekday), 0, 3 )) : substr($weekday, 0, 2 );
+ $values["%a"] = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($weekday), 0, 3 )) : substr($weekday, 0, 3 );
$values["%A"] = $weekday;
$values["%b"] = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($monthStr), 0, 3 )) : substr($monthStr, 0, 3);
$values["%B"] = $monthStr;
@@ -527,6 +534,110 @@
return $text;
}
+ /**
+ * Formats the date of a Timestamp object according to the given format:
+ * This function assumes that the timestamp is local and it converts it
+ * to GMT before formatting.
+ *
+ * (compatible with PHP):
+ * - %a abbreviated weekday
+ * - %A complete weekday
+ * - %b abbreviated month
+ * - %B long month
+ * - %d day of the month, 2 digits with leading zero
+ * - %j day of the month, numeric (without leading zero)
+ * - %H hours, in 24-h format
+ * - %I hours, in 12-h format (without leading zero)
+ * - %p returns 'am' or 'pm'
+ * - %P returns 'AM' or 'PM'
+ * - %M minutes
+ * - %m month number, from 00 to 12
+ * - %S seconds
+ * - %y 2-digit year representation
+ * - %Y 4-digit year representation
+ * - %% the '%' character
+ *
+ * (these have been added by myself and are therefore incompatible with php)
+ * - %T "_day_ of _month_", where the day is in ordinal form and 'month' is the name of the month
+ * - %D cardinal representation of the day
+ *
+ */
+ function formatDateGMT( $timeStamp, $format = null )
+ {
+ // load the file if it hadn't been loaded yet
+ if( !is_array($this->_messages))
+ $this->_loadLocaleFile();
+
+ // Convert this timestamp to on that is in GMT
+ $strTimeStamp = $timeStamp->getTimestamp();
+ // Now have a local time stamp
+ // Is this step really necessary, since we previously had a time stamp
+ $time = mktime(
+ substr($strTimeStamp,8,2),
+ substr($strTimeStamp,10,2),
+ substr($strTimeStamp,12,2),
+ substr($strTimeStamp,4,2),
+ substr($strTimeStamp,6,2),
+ substr($strTimeStamp,0,4)
+ );
+
+ // This does not take into account the time offset that the user
+ // specified, since we are converting the time to GMT. Since the
+ // offset is just used to handle time zone differences, it is not
+ // necessary, as the time GMT is still the same.
+
+ // timestamp only returns the values in english, so we should translate
+ // them before using
+ $monthId = gmdate( "n", $time );
+ $monthStr = $this->_messages["months"][$monthId-1];
+ //print("monthstr: $monthStr");
+ // and the same for the weekdays
+ $weekdayId = gmdate( "w", $time );
+ $weekday = $this->_messages["days"][$weekdayId];
+
+ // if the user did not specify a format, let's use the default one
+ if( $format == null )
+ $format = $this->_dateFormat;
+
+ // now we can continue normally
+ $values["%a"] = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($weekday), 0, 3 )) : substr($weekday, 0, 3 );
+ $values["%A"] = $weekday;
+ $values["%b"] = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($monthStr), 0, 3 )) : substr($monthStr, 0, 3);
+ $values["%B"] = $monthStr;
+ $values["%d"] = gmdate( "d", $time );
+ $values["%e"] = intval(gmdate( "d", $time ));
+ $values["%j"] = gmdate( "j", $time );
+ $values["%H"] = gmdate( "H", $time );
+ $values["%I"] = gmdate( "g", $time );
+ $values["%p"] = gmdate( "a", $time );
+ $values["%P"] = gmdate( "A", $time );
+ $values["%M"] = gmdate( "i", $time );
+ $values["%m"] = gmdate( "m", $time );
+ $values["%S"] = gmdate( "s", $time );
+ $values["%y"] = gmdate( "y", $time );
+ $values["%Y"] = gmdate( "Y", $time );
+ $values["%%"] = "%";
+ $values["%T"] = $this->getDateOrdinal( gmdate( "d", $time ) )." ".$this->tr("of")." ".$monthStr;
+ $values["%D"] = $this->getDateOrdinal( gmdate( "d", $time ) );
+ /* Start Hack By FiFtHeLeMeNt For Persian Language */
+ list( $jyear, $jmonth, $jday ) = JalaliCalendar::gregorian_to_jalali(gmdate( "Y", $time ), gmdate( "m", $time ), gmdate( "d", $time ));
+ $values["%q"] = JalaliCalendar::Convertnumber2farsi($jyear);
+ $values["%w"]= JalaliCalendar::Convertnumber2farsi($jmonth);
+ $values["%o"] = JalaliCalendar::Convertnumber2farsi($jday);
+ $values["%R"] = JalaliCalendar::monthname($jmonth);
+ $values["%T"] = JalaliCalendar::Convertnumber2farsi(gmdate( "H", $time ));
+ $values["%U"] = JalaliCalendar::Convertnumber2farsi(gmdate( "i", $time ));
+ /* End Hack By FiFtHeLeMeNt For Persian Language */
+
+ $text = $format;
+ foreach( array_keys($values) as $key ) {
+ if( ereg($key, $text) )
+ $text = str_replace( $key, $values[$key], $text );
+ }
+
+ return $text;
+ }
+
/**
* merges two locales
*/