CakeTime::format crashed when timezone is passed

This commit is contained in:
Rachman Chavik 2012-05-17 18:52:47 +07:00
parent 4dc07b6d39
commit f89bc6503a
2 changed files with 3 additions and 1 deletions

View file

@ -472,9 +472,11 @@ class CakeTimeTest extends CakeTestCase {
*/
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');

View file

@ -914,7 +914,7 @@ class CakeTime {
*/
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;