Bug #75088 [Opn->Csd]: getTransitions is slow with large values

From: Date: Sun, 14 Jan 2018 13:07:21 +0000
Subject: Bug #75088 [Opn->Csd]: getTransitions is slow with large values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213535@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75088&edit=1 ID: 75088 User updated by: gmblar+php at gmail dot com Reported by: gmblar+php at gmail dot com Summary: getTransitions is slow with large values -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: MacOS 10.13 PHP Version: 7.1.8 Block user comment: N Private report: N New Comment: Fixed in PHP 7.2 Previous Comments: ------------------------------------------------------------------------ [2017-08-17 20:10:39] gmblar+php at gmail dot com Description: ------------ getTransitions is slow with large negative or positive values. With the default values PHP_INT_MIN and PHP_INT_MAX the function takes a very long time. Test script: --------------- <?php function measure_duration(callable $callback) { $start = microtime(true); call_user_func($callback); $duration = microtime(true) - $start; printf("Duration: %s\n\n", number_format($duration, 6)); } $timezone = new DateTimeZone('Europe/Berlin'); measure_duration(function() use($timezone) { printf("Default Value\n"); $timezone->getTransitions(); }); measure_duration(function() use($timezone) { $timestamp = 0; printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp)); $timezone->getTransitions($timestamp); }); measure_duration(function() use($timezone) { $timestamp = -62135596800; printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp)); $timezone->getTransitions($timestamp); }); Expected result: ---------------- Default Value Duration: 0.000268 Timestamp for 1970-01-01 00:00:00 Duration: 0.000134 Timestamp for 0001-01-01 00:00:00 Duration: 0.000161 Actual result: -------------- Default Value Duration: 0.018967 Timestamp for 1970-01-01 00:00:00 Duration: 0.000101 Timestamp for 0001-01-01 00:00:00 Duration: 0.000095 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75088&edit=1

« previous php.bugs (#213535) next »