@@ -3629,6 +3629,15 @@ PHP_FUNCTION(timezone_transitions_get)
36293629 add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
36303630 add_next_index_zval(return_value, &element);
36313631
3632+ #define add_from_tto (to ,ts ) \
3633+ array_init(&element); \
3634+ add_assoc_long(&element, "ts", ts); \
3635+ add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601, 13, ts, 0)); \
3636+ add_assoc_long(&element, "offset", (to)->offset); \
3637+ add_assoc_bool(&element, "isdst", (to)->is_dst); \
3638+ add_assoc_string(&element, "abbr", (to)->abbr); \
3639+ add_next_index_zval(return_value, &element);
3640+
36323641#define add_last () add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
36333642
36343643 array_init (return_value );
@@ -3658,7 +3667,13 @@ PHP_FUNCTION(timezone_transitions_get)
36583667
36593668 if (!found ) {
36603669 if (tzobj -> tzi .tz -> bit64 .timecnt > 0 ) {
3661- add_last ();
3670+ if (tzobj -> tzi .tz -> posix_info && tzobj -> tzi .tz -> posix_info -> dst_end ) {
3671+ timelib_time_offset * tto = timelib_get_time_zone_info (timestamp_begin , tzobj -> tzi .tz );
3672+ add_from_tto (tto , timestamp_begin );
3673+ timelib_time_offset_dtor (tto );
3674+ } else {
3675+ add_last ();
3676+ }
36623677 } else {
36633678 add_nominal ();
36643679 }
@@ -3671,31 +3686,34 @@ PHP_FUNCTION(timezone_transitions_get)
36713686 return ;
36723687 }
36733688 }
3674- if (tzobj -> tzi .tz -> posix_info && tzobj -> tzi .tz -> posix_info -> dst_end ) {
3675- int i , j ;
3676- timelib_sll start_y , end_y , dummy_m , dummy_d ;
3677- timelib_sll last_transition_ts = tzobj -> tzi .tz -> trans [tzobj -> tzi .tz -> bit64 .timecnt - 1 ];
3689+ }
3690+ if (tzobj -> tzi .tz -> posix_info && tzobj -> tzi .tz -> posix_info -> dst_end ) {
3691+ int i , j ;
3692+ timelib_sll start_y , end_y , dummy_m , dummy_d ;
3693+ timelib_sll last_transition_ts = tzobj -> tzi .tz -> trans [tzobj -> tzi .tz -> bit64 .timecnt - 1 ];
36783694
3679- /* Find out year for last transition */
3680- timelib_unixtime2date (last_transition_ts , & start_y , & dummy_m , & dummy_d );
3695+ /* Find out year for last transition */
3696+ timelib_unixtime2date (last_transition_ts , & start_y , & dummy_m , & dummy_d );
36813697
3682- /* Find out year for final boundary timestamp */
3683- timelib_unixtime2date (timestamp_end , & end_y , & dummy_m , & dummy_d );
3698+ /* Find out year for final boundary timestamp */
3699+ timelib_unixtime2date (timestamp_end , & end_y , & dummy_m , & dummy_d );
36843700
3685- for (i = start_y ; i <= end_y ; i ++ ) {
3686- timelib_posix_transitions transitions = { 0 };
3701+ for (i = start_y ; i <= end_y ; i ++ ) {
3702+ timelib_posix_transitions transitions = { 0 };
36873703
3688- timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
3704+ timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
36893705
3690- for (j = 0 ; j < transitions .count ; j ++ ) {
3691- if (transitions .times [j ] <= last_transition_ts ) {
3692- continue ;
3693- }
3694- if (transitions .times [j ] > timestamp_end ) {
3695- return ;
3696- }
3697- add_by_index (transitions .types [j ], transitions .times [j ]);
3706+ for (j = 0 ; j < transitions .count ; j ++ ) {
3707+ if (transitions .times [j ] <= last_transition_ts ) {
3708+ continue ;
3709+ }
3710+ if (transitions .times [j ] < timestamp_begin ) {
3711+ continue ;
3712+ }
3713+ if (transitions .times [j ] > timestamp_end ) {
3714+ return ;
36983715 }
3716+ add_by_index (transitions .types [j ], transitions .times [j ]);
36993717 }
37003718 }
37013719 }
0 commit comments