summaryrefslogtreecommitdiff
path: root/system/helpers/date.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers/date.php')
-rw-r--r--system/helpers/date.php42
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);
}
/**