mlanthaler: Bugfix: Fixed HTTP::gmt_date and added a new method HTTP::register_modification_timestamp().

(merged from branches/gsoc)


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42103 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-16 15:53:35 +00:00
parent 8bc94c17ea
commit 994b485d63

View File

@ -280,10 +280,17 @@ class HTTP {
if($timestamp > self::$modification_date) self::$modification_date = $timestamp; if($timestamp > self::$modification_date) self::$modification_date = $timestamp;
} }
static function register_modification_timestamp($timestamp) {
if($timestamp > self::$modification_date)
self::$modification_date = $timestamp;
}
/** /**
* Add the appropriate caching headers to the response * Add the appropriate caching headers to the response
*
* @param string The reponse body
*/ */
static function add_cache_headers() { static function add_cache_headers($body = null) {
// Development sites have frequently changing templates; this can get stuffed up by the code // Development sites have frequently changing templates; this can get stuffed up by the code
// below. // below.
if(Director::isDev()) return; if(Director::isDev()) return;
@ -312,17 +319,17 @@ class HTTP {
} }
} }
/** /**
* Return an RFC 2822 date in the GMT timezone * Return an {@link http://www.faqs.org/rfcs/rfc2822 RFC 2822} date in the
* GMT timezone (a timestamp is always in GMT: the number of seconds
* since January 1 1970 00:00:00 GMT)
*/ */
static function gmt_date($timestamp) { static function gmt_date($timestamp) {
// Get the timezone offset in seconds return gmdate('D, d M Y H:i:s', $timestamp) . ' GMT';
$timezone = date('O');
$timezoneOffset = (($timezone[0] == '-')?-1:1) * (substr($timezone,1,2)*3600) + (substr($timezone,3,2)*60);
return date('D d M Y h:i:s', $timestamp - $timezoneOffset) . ' GMT (' . $timezoneOffset . ')';
} }
} }
?> ?>