Doc #75790 [Opn->Csd]: DateTimeZone::getTransitions(start,end)[0] is incorrect

From: Date: Thu, 02 Jun 2022 15:37:36 +0000
Subject: Doc #75790 [Opn->Csd]: DateTimeZone::getTransitions(start,end)[0] is incorrect
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19451@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75790&edit=1 ID: 75790 Updated by: git@php.net Reported by: z dot dacto at gmail dot com Summary: DateTimeZone::getTransitions(start,end)[0] is incorrect -Status: Open +Status: Closed Type: Documentation Problem Package: Date/time related Operating System: Linux debian 3.16.0-4-amd64 PHP Version: 5.6.33 Block user comment: N Private report: N New Comment: Automatic comment on behalf of derickr Revision: https://github.com/php/doc-en/commit/ceedf4c5240cf79ea24baa7f2fcffa312aaccda3 Log: Fixed bug #75790: DateTimeZone::getTransitions(start,end)[0] is timestampBegin Previous Comments: ------------------------------------------------------------------------ [2018-01-11 01:57:07] z dot dacto at gmail dot com While it is by design, is this the correct behavior since the first element isn't actually a valid timezone transition? Aside from the what I mentioned in the original description, an alternative interpretation for DateTimeZone::getTransitions(start,end) would be such that only timezone transitions that happen between start and end would be included in the resulting array. Applied to the Test SCript, this should then result in: Array ( [0] => Array ( [ts] => 1509872400 [time] => 2017-11-05T09:00:00+0000 [offset] => -28800 [isdst] => [abbr] => PST ) ) ------------------------------------------------------------------------ [2018-01-10 10:14:11] derick@php.net This is by design, but it does not seem documented. Marking it as a "Documentation Problem". ------------------------------------------------------------------------ [2018-01-10 08:15:34] z dot dacto at gmail dot com Description: ------------ When optional argument $timestamp_begin is provided to DateTimeZone::getTransitions the first transition returned assumes a ts value of $timestamp_begin and a time value formatted from $timestamp_begin. The first transition should instead be the one active during $timestamp_begin. Test script: --------------- <!DOCTYPE html> <html> <body> <pre> <?php $tz = new DateTimeZone('America/Los_Angeles'); # 1509872300 = 11-05-2017T8:58:20+0000 # 1515570270 = 01-10-2018T7:44:30+0000 $transition = $tz->getTransitions(1509872300, 1515570270); print_r($transition); ?> </pre> </body> </html> Expected result: ---------------- Array ( [0] => Array ( [ts] => 1489312800 [time] => 2017-03-12T10:00:00+0000 [offset] => -25200 [isdst] => 1 [abbr] => PDT ) [1] => Array ( [ts] => 1509872400 [time] => 2017-11-05T09:00:00+0000 [offset] => -28800 [isdst] => [abbr] => PST ) ) Actual result: -------------- Array ( [0] => Array ( [ts] => 1509872300 [time] => 2017-11-05T08:58:20+0000 [offset] => -25200 [isdst] => 1 [abbr] => PDT ) [1] => Array ( [ts] => 1509872400 [time] => 2017-11-05T09:00:00+0000 [offset] => -28800 [isdst] => [abbr] => PST ) ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75790&edit=1

« previous php.doc.bugs (#19451) next »