@@ -3629,6 +3629,15 @@ PHP_FUNCTION(timezone_transitions_get)
3629
3629
add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
3630
3630
add_next_index_zval(return_value, &element);
3631
3631
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
+
3632
3641
#define add_last () add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
3633
3642
3634
3643
array_init (return_value );
@@ -3658,7 +3667,13 @@ PHP_FUNCTION(timezone_transitions_get)
3658
3667
3659
3668
if (!found ) {
3660
3669
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
+ }
3662
3677
} else {
3663
3678
add_nominal ();
3664
3679
}
@@ -3671,31 +3686,34 @@ PHP_FUNCTION(timezone_transitions_get)
3671
3686
return ;
3672
3687
}
3673
3688
}
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 ];
3678
3694
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 );
3681
3697
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 );
3684
3700
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 };
3687
3703
3688
- timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
3704
+ timelib_get_transitions_for_year (tzobj -> tzi .tz , i , & transitions );
3689
3705
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 ;
3698
3715
}
3716
+ add_by_index (transitions .types [j ], transitions .times [j ]);
3699
3717
}
3700
3718
}
3701
3719
}
0 commit comments