Bug #81660 [Com]: DateTimeZone::getTransitions() returns invalid data
Edit report at https://bugs.php.net/bug.php?id=81660&edit=1
ID: 81660
Comment by: antonino dot spampinato86 at gmail dot com
Reported by: kenji dot uui at gmail dot com
Summary: DateTimeZone::getTransitions() returns invalid data
Status: Assigned
Type: Bug
Package: Date/time related
Operating System: macOS
PHP Version: 8.1.0
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
Currently @derick's patch from php> = 8.1.0beta3 without parameters returns from one (if it
has never used transition) or more transition arrays.
Otherwise with parameter it returns the last transition period of the year UTC which is different
from its local timezone if different from UTC. 2010-12-31 00:00:00 America/Chicago and 2011-01-01
06:00:00 UTC.
Do you want to calculate the time of the year between two dates?
that is to say:
array(5) {
["ts"]=>
int(1300003200)
["time"]=>
string(24) "2011-03-13T08:00:00+0000"
["offset"]=>
int(-18000)
["isdst"]=>
bool(true)
["abbr"]=>
string(3) "CDT"
}
relative to fix bug 80963
Previous Comments:
------------------------------------------------------------------------
[2021-11-26 10:00:13] cmb@php.net
Confirmed: <https://3v4l.org/MtJ2X>.
<https://www.timeanddate.com/time/zone/usa/chicago>
agrees with
behavior prior to PHP 8.1.0.
------------------------------------------------------------------------
[2021-11-26 06:49:50] kenji dot uui at gmail dot com
Description:
------------
DateTimeZone::getTransitions() changed between PHP 8.0.13 and 8.1.0.
Test script:
---------------
<?php
$tz = new DateTimeZone('America/Chicago');
$start = 1293861600;
$end = 1357020000;
$transitions = $tz->getTransitions($start, $end);
var_dump($transitions);
Expected result:
----------------
array(5) {
[0]=>
array(5) {
["ts"]=>
int(1293861600)
["time"]=>
string(24) "2011-01-01T06:00:00+0000"
["offset"]=>
int(-21600)
["isdst"]=>
bool(false)
["abbr"]=>
string(3) "CST"
}
[1]=>
array(5) {
["ts"]=>
int(1300003200)
["time"]=>
string(24) "2011-03-13T08:00:00+0000"
["offset"]=>
int(-18000)
["isdst"]=>
bool(true)
["abbr"]=>
string(3) "CDT"
}
[2]=>
array(5) {
["ts"]=>
int(1320562800)
["time"]=>
string(24) "2011-11-06T07:00:00+0000"
["offset"]=>
int(-21600)
["isdst"]=>
bool(false)
["abbr"]=>
string(3) "CST"
}
[3]=>
array(5) {
["ts"]=>
int(1331452800)
["time"]=>
string(24) "2012-03-11T08:00:00+0000"
["offset"]=>
int(-18000)
["isdst"]=>
bool(true)
["abbr"]=>
string(3) "CDT"
}
[4]=>
array(5) {
["ts"]=>
int(1352012400)
["time"]=>
string(24) "2012-11-04T07:00:00+0000"
["offset"]=>
int(-21600)
["isdst"]=>
bool(false)
["abbr"]=>
string(3) "CST"
}
}
Actual result:
--------------
array(1) {
[0]=>
array(5) {
["ts"]=>
int(1293861600)
["time"]=>
string(24) "2011-01-01T06:00:00+0000"
["offset"]=>
int(-18000)
["isdst"]=>
bool(true)
["abbr"]=>
string(3) "CDT"
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81660&edit=1
Thread (5 messages)