Bug #75167 [NEW]: DateTime::add does only care about backward DST transition, not forward

From: Date: Thu, 07 Sep 2017 11:42:19 +0000
Subject: Bug #75167 [NEW]: DateTime::add does only care about backward DST transition, not forward
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210991@lists.php.net to get a copy of this message
From: knutoh at gmail dot com Operating system: irrelevant PHP version: 7.1.9 Package: Date/time related Bug Type: Bug Bug description:DateTime::add does only care about backward DST transition, not forward Description: ------------ This change in this commit: http://git.php.net/?p=php-src.git;a=blobdiff;f=ext/date/lib/interval.c;h=dce62f3a2803db69af026105f8c862806c512bcf;hp=7fa1fc5c13f24c05ddae53b9fa952bca344ff318;hb=582f6e529e843b412d582023bf0270e47b1aa468;hpb=5d0c526199add0e4f054a57db29d882c8ad89a23 fixes so that DateTime::sub and DateTime::add handles DST transitions correctly. But derickr probably just forgot to handle forward DST transition in the DateTime::add function. Test script: --------------- $tz = new DateTimeZone('Europe/London'); // A timezone that has DST $five_hours_interval = new DateInterval('PT5H'); $date = new DateTime("2014-3-30 00:00:00", $tz); // Add five hours and subtract 5 hours. The $newDate should then equal the date. $five_hours_later = (clone $date)->add($five_hours_interval); $newDate = (clone $five_hours_later)->sub($five_hours_interval); echo $date->format('c') . "\n"; echo $newDate->format('c'); Expected result: ---------------- 2014-03-30T00:00:00+00:00 2014-03-30T00:00:00+00:00 Actual result: -------------- 2014-03-30T00:00:00+00:00 2014-03-29T23:00:00+00:00 -- Edit bug report at https://bugs.php.net/bug.php?id=75167&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75167&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75167&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75167&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75167&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75167&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75167&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75167&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75167&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75167&r=support Expected behavior: https://bugs.php.net/fix.php?id=75167&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75167&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75167&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75167&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75167&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75167&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75167&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75167&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75167&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75167&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75167&r=mysqlcfg

« previous php.bugs (#210991) next »