From 9b6663f87a7e679ffba691cf516191fc840cf978 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 Nov 2009 19:20:36 -0800 Subject: Update to Kohana r4684 which is now Kohana 2.4 and has substantial changes. --- system/helpers/date.php | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'system/helpers/date.php') diff --git a/system/helpers/date.php b/system/helpers/date.php index 7d5a9ab6..af7e85bd 100644 --- a/system/helpers/date.php +++ b/system/helpers/date.php @@ -2,12 +2,12 @@ /** * Date helper class. * - * $Id: date.php 4316 2009-05-04 01:03:54Z kiall $ + * $Id: date.php 4679 2009-11-10 01:45:52Z isaiah $ * * @package Core * @author Kohana Team - * @copyright (c) 2007-2008 Kohana Team - * @license http://kohanaphp.com/license.html + * @copyright (c) 2007-2009 Kohana Team + * @license http://kohanaphp.com/license */ class date_Core { @@ -57,36 +57,28 @@ class date_Core { * Returns the offset (in seconds) between two time zones. * @see http://php.net/timezones * - * @param string timezone that to find the offset of + * @param string timezone to find the offset of * @param string|boolean timezone used as the baseline + * @param string time at which to calculate * @return integer */ - public static function offset($remote, $local = TRUE) + public static function offset($remote, $local = TRUE, $when = 'now') { - static $offsets; - - // Default values - $remote = (string) $remote; - $local = ($local === TRUE) ? date_default_timezone_get() : (string) $local; - - // Cache key name - $cache = $remote.$local; - - if (empty($offsets[$cache])) + if ($local === TRUE) { - // Create timezone objects - $remote = new DateTimeZone($remote); - $local = new DateTimeZone($local); + $local = date_default_timezone_get(); + } - // Create date objects from timezones - $time_there = new DateTime('now', $remote); - $time_here = new DateTime('now', $local); + // Create timezone objects + $remote = new DateTimeZone($remote); + $local = new DateTimeZone($local); - // Find the offset - $offsets[$cache] = $remote->getOffset($time_there) - $local->getOffset($time_here); - } + // Create date objects from timezones + $time_there = new DateTime($when, $remote); + $time_here = new DateTime($when, $local); - return $offsets[$cache]; + // Find the offset + return $remote->getOffset($time_there) - $local->getOffset($time_here); } /** -- cgit v1.2.3