Added "Config.timezone" config param to avoid having to specify timezone in each function call.

This commit is contained in:
ADmad 2012-04-13 09:36:43 +05:30
parent d34f0c2bd8
commit ebf304927b
2 changed files with 9 additions and 0 deletions

View file

@ -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');
}
/**

View file

@ -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);
}