xref: /PHP-8.3/ext/date/tests/bug73460-002.phpt (revision 091c0920)
1--TEST--
2Bug #73460 (Datetime add not realising it already applied DST change)
3--FILE--
4<?php
5
6date_default_timezone_set('America/New_York');
7
8//DST starts Apr. 2nd 02:00 and moves to 03:00
9$start = new \DateTime('2006-04-02T01:00:00');
10$end = new \DateTime('2006-04-02T04:00:00');
11
12while($end > $start) {
13    $now = clone $end;
14    $end->sub(new \DateInterval('PT1H'));
15    echo $end->format('Y-m-d H:i T') . PHP_EOL;
16}
17
18echo '-----' . \PHP_EOL;
19
20//DST ends Oct. 29th 02:00 and moves to 01:00
21$start = new \DateTime('2006-10-29T00:30:00');
22$end = new \DateTime('2006-10-29T03:00:00');
23
24$i = 0;
25while($end > $start) {
26    $now = clone $start;
27    $start->add(new \DateInterval('PT30M'));
28    echo $start->format('Y-m-d H:i T') . PHP_EOL;
29}
30?>
31--EXPECT--
322006-04-02 03:00 EDT
332006-04-02 01:00 EST
34-----
352006-10-29 01:00 EDT
362006-10-29 01:30 EDT
372006-10-29 01:00 EST
382006-10-29 01:30 EST
392006-10-29 02:00 EST
402006-10-29 02:30 EST
412006-10-29 03:00 EST
42