From ebf304927b80ec77ca27324f2e67c8aa7f647f63 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 13 Apr 2012 09:36:43 +0530 Subject: [PATCH] Added "Config.timezone" config param to avoid having to specify timezone in each function call. --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 5 +++++ lib/Cake/Utility/CakeTime.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 27a7f7c4a..dffb7cc97 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -630,6 +630,11 @@ class CakeTimeTest extends CakeTestCase { $result = $this->Time->fromString(time(), $timezoneServer); $this->assertEquals($expected, $result); + + Configure::write('Config.timezone', $timezoneServer->getName()); + $result = $this->Time->fromString(time()); + $this->assertEquals($expected, $result); + Configure::delete('Config.timezone'); } /** diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index fa6427032..6078863d2 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -243,6 +243,10 @@ class CakeTime { $date = strtotime($dateString); } + if ($timezone === null) { + $timezone = Configure::read('Config.timezone'); + } + if ($timezone !== null) { return self::convert($date, $timezone); }