mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 07:29:51 +00:00
Using fixed points in time.
This avoids lulz when the United Kingdom changes change to/from DST at a different time than your local timezone.
This commit is contained in:
parent
494928a6d7
commit
e8f727fe68
1 changed files with 12 additions and 11 deletions
|
@ -474,7 +474,7 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
$serverTime = new DateTime('now');
|
$serverTime = new DateTime('2012-12-11 14:15:20');
|
||||||
|
|
||||||
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
|
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
|
||||||
foreach ($timezones as $timezone) {
|
foreach ($timezones as $timezone) {
|
||||||
|
@ -509,17 +509,18 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testToRss() {
|
public function testToRss() {
|
||||||
$this->assertEquals(date('r'), $this->Time->toRss(time()));
|
$date = '2012-08-12 12:12:45';
|
||||||
|
$time = strtotime($date);
|
||||||
|
$this->assertEquals(date('r', $time), $this->Time->toRss($time));
|
||||||
|
|
||||||
if (!$this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) {
|
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
|
||||||
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
|
foreach ($timezones as $timezone) {
|
||||||
foreach ($timezones as $timezone) {
|
$yourTimezone = new DateTimeZone($timezone);
|
||||||
$yourTimezone = new DateTimeZone($timezone);
|
$yourTime = new DateTime($date, $yourTimezone);
|
||||||
$yourTime = new DateTime('now', $yourTimezone);
|
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
|
||||||
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
|
$time = $yourTime->getTimestamp();
|
||||||
$this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
|
$this->assertEquals($yourTime->format('r'), $this->Time->toRss($time, $userOffset), "Failed on $timezone");
|
||||||
$this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $timezone));
|
$this->assertEquals($yourTime->format('r'), $this->Time->toRss($time, $timezone), "Failed on $timezone");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue