Bug #81287 [NEW]: TimeZone::getTransitions Not Working

From: Date: Sun, 25 Jul 2021 05:10:40 +0000
Subject: Bug #81287 [NEW]: TimeZone::getTransitions Not Working
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235330@lists.php.net to get a copy of this message
From:             eclipsechasers2 at yahoo dot com
Operating system: Windows 10
PHP version:      8.1.0beta1
Package:          Date/time related
Bug Type:         Bug
Bug description:TimeZone::getTransitions Not Working

Description:
------------
In PHP8.0 and PHP7.*, the code below produces an array of 5 items, with
offset toggling back and forth between -14400 and -18000, and with abbr
toggling between EDT and EST. In PHP8.1, it produces an array of 1 item,
with an (incorrect) offset of -14400 and (incorrect) abbr of EDT. The
timestamps match between 8.1 and other releases, so the problem must be
in getTransitions.

I chose 8.1Beta1 as best match; in fact, my version is:
PHP 8.1.0-dev (cli) (built: Jul 24 2021 23:42:29) (NTS Visual C++ 2019
x64)


Test script:
---------------
$timeZone = new DateTimeZone('America/Toronto');
$timestamp = '2008-01-01 12:00:00';
$dtobj = DateTime::createFromFormat('Y-m-d H:i:s', $timestamp);
$tstmp = $dtobj->getTimestamp();
$timestam2 = '2010-01-01 12:00:00';
$dtob2 = DateTime::createFromFormat('Y-m-d H:i:s', $timestam2);
$tstm2 = $dtob2->getTimestamp();
var_dump($tstmp, $tstm2);
$transitions = $timeZone->getTransitions($tstmp, $tstm2);
var_dump($transitions);

Expected result:
----------------
I expect the same result as in other releases - 5 items in array,
toggling between EDT and EST, and between an offset of -18000 and
-14400.

int(1199217600)
int(1262376000)
array(5) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(1199217600)
    ["time"]=>
    string(24) "2008-01-01T20:00:00+0000"
    ["offset"]=>
    int(-18000)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "EST"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(1205046000)
    ["time"]=>
    string(24) "2008-03-09T07:00:00+0000"
    ["offset"]=>
    int(-14400)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(3) "EDT"
  }
  [2]=>
  array(5) {
    ["ts"]=>
    int(1225605600)
    ["time"]=>
    string(24) "2008-11-02T06:00:00+0000"
    ["offset"]=>
    int(-18000)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "EST"
  }
  [3]=>
  array(5) {
    ["ts"]=>
    int(1236495600)
    ["time"]=>
    string(24) "2009-03-08T07:00:00+0000"
    ["offset"]=>
    int(-14400)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(3) "EDT"
  }
  [4]=>
  array(5) {
    ["ts"]=>
    int(1257055200)
    ["time"]=>
    string(24) "2009-11-01T06:00:00+0000"
    ["offset"]=>
    int(-18000)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "EST"
  }
}


Actual result:
--------------
int(1199188800)
int(1262347200)
array(1) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(1199188800)
    ["time"]=>
    string(24) "2008-01-01T12:00:00+0000"
    ["offset"]=>
    int(-14400)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(3) "EDT"
  }
}

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81287&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81287&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81287&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81287&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81287&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81287&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81287&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81287&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81287&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81287&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81287&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81287&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81287&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81287&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81287&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81287&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81287&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81287&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#235330) next »