Skip to content

Commit

Permalink
CakeTime::format crashed when timezone is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed May 17, 2012
1 parent 4dc07b6 commit f89bc65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -472,9 +472,11 @@ public function testToRss() {
*/
public function testFormat() {
$format = 'D-M-Y';
$tz = date_default_timezone_get();
$arr = array(time(), strtotime('+1 days'), strtotime('+1 days'), strtotime('+0 days'));
foreach ($arr as $val) {
$this->assertEquals(date($format, $val), $this->Time->format($format, $val));
$this->assertEquals(date($format, $val), $this->Time->format($format, $val, false, $tz));
}

$result = $this->Time->format('Y-m-d', null, 'never');
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/CakeTime.php
Expand Up @@ -914,7 +914,7 @@ public static function gmt($string = null) {
*/
public static function format($format, $date = null, $invalid = false, $timezone = null) {
$time = self::fromString($date, $timezone);
$_time = self::fromString($format, $timezone);
$_time = is_numeric($time) ? false : self::fromString($format, $timezone);

if (is_numeric($_time) && $time === false) {
$format = $date;
Expand Down

0 comments on commit f89bc65

Please sign in to comment.