mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-17 06:59:51 +00:00
CakeTime::format crashed when timezone is passed
This commit is contained in:
parent
4dc07b6d39
commit
f89bc6503a
2 changed files with 3 additions and 1 deletions
|
@ -472,9 +472,11 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testFormat() {
|
public function testFormat() {
|
||||||
$format = 'D-M-Y';
|
$format = 'D-M-Y';
|
||||||
|
$tz = date_default_timezone_get();
|
||||||
$arr = array(time(), strtotime('+1 days'), strtotime('+1 days'), strtotime('+0 days'));
|
$arr = array(time(), strtotime('+1 days'), strtotime('+1 days'), strtotime('+0 days'));
|
||||||
foreach ($arr as $val) {
|
foreach ($arr as $val) {
|
||||||
$this->assertEquals(date($format, $val), $this->Time->format($format, $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');
|
$result = $this->Time->format('Y-m-d', null, 'never');
|
||||||
|
|
|
@ -914,7 +914,7 @@ class CakeTime {
|
||||||
*/
|
*/
|
||||||
public static function format($format, $date = null, $invalid = false, $timezone = null) {
|
public static function format($format, $date = null, $invalid = false, $timezone = null) {
|
||||||
$time = self::fromString($date, $timezone);
|
$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) {
|
if (is_numeric($_time) && $time === false) {
|
||||||
$format = $date;
|
$format = $date;
|
||||||
|
|
Loading…
Add table
Reference in a new issue