mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
CakeTime no longer sets the timezone out of its scope on the date object
This commit is contained in:
parent
e2781a536a
commit
db7d5426ec
2 changed files with 10 additions and 2 deletions
|
@ -816,6 +816,13 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$result = $this->Time->fromString('+1 hour', $timezone);
|
||||
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
$date = new DateTime('now', new DateTimeZone('Europe/London'));
|
||||
$this->Time->fromString($date);
|
||||
$this->assertEquals('Europe/London', $date->getTimeZone()->getName());
|
||||
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -315,8 +315,9 @@ class CakeTime {
|
|||
if (is_integer($dateString) || is_numeric($dateString)) {
|
||||
$date = intval($dateString);
|
||||
} elseif (is_object($dateString) && $dateString instanceof DateTime) {
|
||||
$dateString->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$date = (int)$dateString->format('U') + $dateString->getOffset();
|
||||
$clone = clone $dateString;
|
||||
$clone->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$date = (int)$clone->format('U') + $clone->getOffset();
|
||||
} else {
|
||||
$date = strtotime($dateString);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue