diff options
author | Andreas Fischer <bantu@phpbb.com> | 2009-12-10 01:12:54 +0000 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2009-12-10 01:12:54 +0000 |
commit | 56cc34602b7bae811165ce7697e200af47b0e6f8 (patch) | |
tree | b69556f3c2c2bbbb9c55fa162ed5c83c9a5002fa /phpBB/feed.php | |
parent | b577dece4489c5afde5b7fa0839091b2f0088159 (diff) | |
download | forums-56cc34602b7bae811165ce7697e200af47b0e6f8.tar forums-56cc34602b7bae811165ce7697e200af47b0e6f8.tar.gz forums-56cc34602b7bae811165ce7697e200af47b0e6f8.tar.bz2 forums-56cc34602b7bae811165ce7697e200af47b0e6f8.tar.xz forums-56cc34602b7bae811165ce7697e200af47b0e6f8.zip |
Correctly use RFC 3339 date in ATOM feeds. Bug #55005
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10312 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/feed.php')
-rw-r--r-- | phpBB/feed.php | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/phpBB/feed.php b/phpBB/feed.php index d658e2993b..2670c022cb 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -35,15 +35,12 @@ $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $mode = request_var('mode', ''); -// Feed date format for PHP > 5 and PHP4 -$feed_date_format = (PHP_VERSION >= 5) ? 'c' : "Y-m-d\TH:i:sO"; -$params = false; - // We do not use a template, therefore we simply define the global template variables here $global_vars = $item_vars = array(); $feed_updated_time = 0; // Generate params array for use in append_sid() to correctly link back to this page +$params = false; if ($forum_id || $topic_id || $mode) { $params = array( @@ -94,7 +91,7 @@ while ($row = $feed->get_item()) $item_row = array( 'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '', - 'pubdate' => $user->format_date($item_time, $feed_date_format, true), + 'pubdate' => feed_format_date($item_time), 'link' => '', 'title' => censor_text($title), 'category' => ($config['feed_item_statistics']) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', @@ -125,7 +122,7 @@ $global_vars = array_merge($global_vars, array( 'FEED_LINK' => $board_url . '/index.' . $phpEx, 'FEED_TITLE' => $config['sitename'], 'FEED_SUBTITLE' => $config['site_desc'], - 'FEED_UPDATED' => $user->format_date($feed_updated_time, $feed_date_format, true), + 'FEED_UPDATED' => feed_format_date($feed_updated_time), 'FEED_LANG' => $user->lang['USER_LANG'], 'FEED_AUTHOR' => $config['sitename'], )); @@ -225,6 +222,33 @@ function feed_append_sid($url, $params) } /** +* Generate ISO 8601 date string (RFC 3339) +**/ +function feed_format_date($time) +{ + static $zone_offset; + static $offset_string; + + if (empty($offset_string)) + { + global $user; + + $zone_offset = (int) $user->timezone + (int) $user->dst; + + $sign = ($zone_offset < 0) ? '-' : '+'; + $time_offset = abs($zone_offset); + + $offset_seconds = $time_offset % 3600; + $offset_minutes = $offset_seconds / 60; + $offset_hours = ($time_offset - $offset_seconds) / 3600; + + $offset_string = sprintf("%s%02d:%02d", $sign, $offset_hours, $offset_minutes); + } + + return gmdate("Y-m-d\TH:i:s", $time + $zone_offset) . $offset_string; +} + +/** * Generate text content **/ function feed_generate_content($content, $uid, $bitfield, $options) |