Skip to content

Commit

Permalink
Added "Config.timezone" config param to avoid having to specify timez…
Browse files Browse the repository at this point in the history
…one in each function call.
  • Loading branch information
ADmad committed Apr 21, 2012
1 parent d34f0c2 commit ebf3049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -630,6 +630,11 @@ public function testUserOffset() {

$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');
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/Utility/CakeTime.php
Expand Up @@ -243,6 +243,10 @@ public static function fromString($dateString, $timezone = null) {
$date = strtotime($dateString);
}

if ($timezone === null) {
$timezone = Configure::read('Config.timezone');
}

if ($timezone !== null) {
return self::convert($date, $timezone);
}
Expand Down

0 comments on commit ebf3049

Please sign in to comment.