Skip to content

Commit ebf3049

Browse files
committed
Added "Config.timezone" config param to avoid having to specify timezone in each function call.
1 parent d34f0c2 commit ebf3049

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Cake/Test/Case/Utility/CakeTimeTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ public function testUserOffset() {
630630

631631
$result = $this->Time->fromString(time(), $timezoneServer);
632632
$this->assertEquals($expected, $result);
633+
634+
Configure::write('Config.timezone', $timezoneServer->getName());
635+
$result = $this->Time->fromString(time());
636+
$this->assertEquals($expected, $result);
637+
Configure::delete('Config.timezone');
633638
}
634639

635640
/**

lib/Cake/Utility/CakeTime.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ public static function fromString($dateString, $timezone = null) {
243243
$date = strtotime($dateString);
244244
}
245245

246+
if ($timezone === null) {
247+
$timezone = Configure::read('Config.timezone');
248+
}
249+
246250
if ($timezone !== null) {
247251
return self::convert($date, $timezone);
248252
}

0 commit comments

Comments
 (0)