diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-11-24 19:20:36 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-11-24 19:20:36 -0800 |
commit | 9b6663f87a7e679ffba691cf516191fc840cf978 (patch) | |
tree | 20cf9f3aaf93b4ba69d282dcf10d259db4a752de /system/helpers/date.php | |
parent | 82ee5f9d338017c69331b2907f37a468ced8c66e (diff) |
Update to Kohana r4684 which is now Kohana 2.4 and has substantial
changes.
Diffstat (limited to 'system/helpers/date.php')
-rw-r--r-- | system/helpers/date.php | 42 |
1 files changed, 17 insertions, 25 deletions
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); } /** |