php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72255 DST-handling in DatePeriod on transition back is buggy
Submitted: 2016-05-23 05:51 UTC Modified: 2017-03-19 11:58 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: heiglandreas@php.net Assigned:
Status: Duplicate Package: Date/time related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2016-05-23 05:51 UTC] heiglandreas@php.net
Description:
------------
Handling the transition back from DST to default time is buggy in DatePeriod.

The extra hour is not showing when iterating over a DatePeriod covering the transition back from DST to default time.


See https://gist.github.com/heiglandreas/7b7fc82471f4619f66f329a31b566112 and https://3v4l.org/2aDp3 for code-examples.



Test script:
---------------
<?php
$interval = new DateInterval('PT1H');
// DST change in Europe is on the 30. October 2016
$dateTimeStart =  new DateTimeImmutable('2016-10-30 01:30:00', new DateTimezone('Europe/Berlin'));
$dateTimeEnd   =  new DateTimeImmutable('2016-10-30 03:31:00', new DateTimezone('Europe/Berlin'));
$period = new DatePeriod($dateTimeStart, $interval, $dateTimeEnd);
foreach ($period as $date) {
    echo $date->format('c') . "\n";
}

Expected result:
----------------
2016-10-30T01:30:00+02:00
2016-10-30T02:30:00+02:00
2016-10-30T02:30:00+01:00
2016-10-30T03:30:00+01:00

Actual result:
--------------
2016-10-30T01:30:00+02:00
2016-10-30T02:30:00+01:00
2016-10-30T03:30:00+01:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-19 11:58 UTC] heiglandreas@php.net
-Status: Open +Status: Duplicate
 [2017-03-19 11:58 UTC] heiglandreas@php.net
We're now tracking this in https://bugs.php.net/bug.php?id=74274
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jan 24 10:01:24 2020 UTC