Browse files

CakeTime::format crashed when timezone is passed

  • Loading branch information...
1 parent 4dc07b6 commit f89bc6503af376a5d277692ed32d8df8c1c24784 @rchavik rchavik committed May 17, 2012
Showing with 3 additions and 1 deletion.
  1. +2 −0 lib/Cake/Test/Case/Utility/CakeTimeTest.php
  2. +1 −1 lib/Cake/Utility/CakeTime.php
View
2 lib/Cake/Test/Case/Utility/CakeTimeTest.php
@@ -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');
View
2 lib/Cake/Utility/CakeTime.php
@@ -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;

0 comments on commit f89bc65

Please sign in to comment.