Skip to content

Commit 68b874d

Browse files
committed
Fixed bug #81504: Incorrect timezone transition details for POSIX data
1 parent e91a751 commit 68b874d

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
Doleček)
1111
. Fixed bug #81380 (Observer may not be initialized properly). (krakjoe)
1212

13+
- Date:
14+
. Fixed bug #81504 (Incorrect timezone transition details for POSIX data).
15+
(Derick)
16+
1317
- PCRE:
1418
. Unfixed bug #81424 (PCRE2 10.35 JIT performance regression). (cmb)
1519

ext/date/php_date.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3620,6 +3620,15 @@ PHP_FUNCTION(timezone_transitions_get)
36203620
add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx]); \
36213621
add_next_index_zval(return_value, &element);
36223622

3623+
#define add_by_index(i,ts) \
3624+
array_init(&element); \
3625+
add_assoc_long(&element, "ts", ts); \
3626+
add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601, 13, ts, 0)); \
3627+
add_assoc_long(&element, "offset", tzobj->tzi.tz->type[i].offset); \
3628+
add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[i].isdst); \
3629+
add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
3630+
add_next_index_zval(return_value, &element);
3631+
36233632
#define add_last() add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
36243633

36253634
array_init(return_value);
@@ -3685,7 +3694,7 @@ PHP_FUNCTION(timezone_transitions_get)
36853694
if (transitions.times[j] > timestamp_end) {
36863695
return;
36873696
}
3688-
add(transitions.types[j], transitions.times[j]);
3697+
add_by_index(transitions.types[j], transitions.times[j]);
36893698
}
36903699
}
36913700
}

ext/date/tests/bug81504.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #81504: Incorrect timezone transition details for POSIX data
3+
--FILE--
4+
<?php
5+
6+
$tz = new DateTimeZone('Europe/Amsterdam');
7+
foreach ($tz->getTransitions(strtotime("1996-01-01"), strtotime("1997-12-31")) as $tr) {
8+
echo "{$tr['time']} {$tr['offset']} {$tr['abbr']}\n";
9+
}
10+
?>
11+
--EXPECT--
12+
1996-01-01T00:00:00+0000 3600 CET
13+
1996-03-31T01:00:00+0000 7200 CEST
14+
1996-10-27T01:00:00+0000 3600 CET
15+
1997-03-30T01:00:00+0000 7200 CEST
16+
1997-10-26T01:00:00+0000 3600 CET

0 commit comments

Comments
 (0)