@@ -3631,6 +3631,15 @@ PHP_FUNCTION(timezone_transitions_get)
3631
3631
add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
3632
3632
add_next_index_zval(return_value, &element);
3633
3633
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
+
3634
3643
#define add_last () add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
3635
3644
3636
3645
array_init (return_value );
@@ -3660,7 +3669,13 @@ PHP_FUNCTION(timezone_transitions_get)
3660
3669
3661
3670
if (!found ) {
3662
3671
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
+ }
3664
3679
} else {
3665
3680
add_nominal ();
3666
3681
}
@@ -3673,31 +3688,34 @@ PHP_FUNCTION(timezone_transitions_get)
3673
3688
return ;
3674
3689
}
3675
3690
}
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 ];
3680
3696
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 );
3683
3699
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 );
3686
3702
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 };
3689
3705
3690
- timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
3706
+ timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
3691
3707
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 ;
3700
3717
}
3718
+ add_by_index (transitions .types [j ], transitions .times [j ]);
3701
3719
}
3702
3720
}
3703
3721
}
0 commit comments