@@ -3631,6 +3631,15 @@ PHP_FUNCTION(timezone_transitions_get)
36313631 add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
36323632 add_next_index_zval(return_value, &element);
36333633
3634+ #define add_from_tto (to ,ts ) \
3635+ array_init(&element); \
3636+ add_assoc_long(&element, "ts", ts); \
3637+ add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601, 13, ts, 0)); \
3638+ add_assoc_long(&element, "offset", (to)->offset); \
3639+ add_assoc_bool(&element, "isdst", (to)->is_dst); \
3640+ add_assoc_string(&element, "abbr", (to)->abbr); \
3641+ add_next_index_zval(return_value, &element);
3642+
36343643#define add_last () add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
36353644
36363645 array_init (return_value );
@@ -3660,7 +3669,13 @@ PHP_FUNCTION(timezone_transitions_get)
36603669
36613670 if (!found ) {
36623671 if (tzobj -> tzi .tz -> bit64 .timecnt > 0 ) {
3663- add_last ();
3672+ if (tzobj -> tzi .tz -> posix_info && tzobj -> tzi .tz -> posix_info -> dst_end ) {
3673+ timelib_time_offset * tto = timelib_get_time_zone_info (timestamp_begin , tzobj -> tzi .tz );
3674+ add_from_tto (tto , timestamp_begin );
3675+ timelib_time_offset_dtor (tto );
3676+ } else {
3677+ add_last ();
3678+ }
36643679 } else {
36653680 add_nominal ();
36663681 }
@@ -3673,31 +3688,34 @@ PHP_FUNCTION(timezone_transitions_get)
36733688 return ;
36743689 }
36753690 }
3676- if (tzobj -> tzi .tz -> posix_info && tzobj -> tzi .tz -> posix_info -> dst_end ) {
3677- int i , j ;
3678- timelib_sll start_y , end_y , dummy_m , dummy_d ;
3679- timelib_sll last_transition_ts = tzobj -> tzi .tz -> trans [tzobj -> tzi .tz -> bit64 .timecnt - 1 ];
3691+ }
3692+ if (tzobj -> tzi .tz -> posix_info && tzobj -> tzi .tz -> posix_info -> dst_end ) {
3693+ int i , j ;
3694+ timelib_sll start_y , end_y , dummy_m , dummy_d ;
3695+ timelib_sll last_transition_ts = tzobj -> tzi .tz -> trans [tzobj -> tzi .tz -> bit64 .timecnt - 1 ];
36803696
3681- /* Find out year for last transition */
3682- timelib_unixtime2date (last_transition_ts , & start_y , & dummy_m , & dummy_d );
3697+ /* Find out year for last transition */
3698+ timelib_unixtime2date (last_transition_ts , & start_y , & dummy_m , & dummy_d );
36833699
3684- /* Find out year for final boundary timestamp */
3685- timelib_unixtime2date (timestamp_end , & end_y , & dummy_m , & dummy_d );
3700+ /* Find out year for final boundary timestamp */
3701+ timelib_unixtime2date (timestamp_end , & end_y , & dummy_m , & dummy_d );
36863702
3687- for (i = start_y ; i <= end_y ; i ++ ) {
3688- timelib_posix_transitions transitions = { 0 };
3703+ for (i = start_y ; i <= end_y ; i ++ ) {
3704+ timelib_posix_transitions transitions = { 0 };
36893705
3690- timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
3706+ timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
36913707
3692- for (j = 0 ; j < transitions .count ; j ++ ) {
3693- if (transitions .times [j ] <= last_transition_ts ) {
3694- continue ;
3695- }
3696- if (transitions .times [j ] > timestamp_end ) {
3697- return ;
3698- }
3699- add_by_index (transitions .types [j ], transitions .times [j ]);
3708+ for (j = 0 ; j < transitions .count ; j ++ ) {
3709+ if (transitions .times [j ] <= last_transition_ts ) {
3710+ continue ;
3711+ }
3712+ if (transitions .times [j ] < timestamp_begin ) {
3713+ continue ;
3714+ }
3715+ if (transitions .times [j ] > timestamp_end ) {
3716+ return ;
37003717 }
3718+ add_by_index (transitions .types [j ], transitions .times [j ]);
37013719 }
37023720 }
37033721 }
0 commit comments