@@ -4264,6 +4264,7 @@ PHP_FUNCTION(timezone_transitions_get)
4264
4264
uint64_t begin = 0 ;
4265
4265
bool found ;
4266
4266
zend_long timestamp_begin = ZEND_LONG_MIN , timestamp_end = INT32_MAX ;
4267
+ zend_long timestamp_added_last = ZEND_LONG_MIN ;
4267
4268
4268
4269
if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "O|ll" , & object , date_ce_timezone , & timestamp_begin , & timestamp_end ) == FAILURE ) {
4269
4270
RETURN_THROWS ();
@@ -4281,34 +4282,44 @@ PHP_FUNCTION(timezone_transitions_get)
4281
4282
add_assoc_long(&element, "offset", tzobj->tzi.tz->type[0].offset); \
4282
4283
add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[0].isdst); \
4283
4284
add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[0].abbr_idx]); \
4284
- add_next_index_zval(return_value, &element);
4285
+ add_next_index_zval(return_value, &element); \
4286
+ timestamp_added_last = timestamp_begin;
4285
4287
4286
4288
#define add (i ,ts ) \
4287
- array_init(&element); \
4288
- add_assoc_long(&element, "ts", ts); \
4289
- add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4290
- add_assoc_long(&element, "offset", tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].offset); \
4291
- add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].isdst); \
4292
- add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx]); \
4293
- add_next_index_zval(return_value, &element);
4289
+ if (ts > timestamp_added_last) { \
4290
+ array_init(&element); \
4291
+ add_assoc_long(&element, "ts", ts); \
4292
+ add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4293
+ add_assoc_long(&element, "offset", tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].offset); \
4294
+ add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].isdst); \
4295
+ add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx]); \
4296
+ add_next_index_zval(return_value, &element); \
4297
+ timestamp_added_last = ts; \
4298
+ }
4294
4299
4295
4300
#define add_by_index (i ,ts ) \
4296
- array_init(&element); \
4297
- add_assoc_long(&element, "ts", ts); \
4298
- add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4299
- add_assoc_long(&element, "offset", tzobj->tzi.tz->type[i].offset); \
4300
- add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[i].isdst); \
4301
- add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
4302
- add_next_index_zval(return_value, &element);
4301
+ if (ts > timestamp_added_last) { \
4302
+ array_init(&element); \
4303
+ add_assoc_long(&element, "ts", ts); \
4304
+ add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4305
+ add_assoc_long(&element, "offset", tzobj->tzi.tz->type[i].offset); \
4306
+ add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[i].isdst); \
4307
+ add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
4308
+ add_next_index_zval(return_value, &element); \
4309
+ timestamp_added_last = ts; \
4310
+ }
4303
4311
4304
4312
#define add_from_tto (to ,ts ) \
4305
- array_init(&element); \
4306
- add_assoc_long(&element, "ts", ts); \
4307
- add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4308
- add_assoc_long(&element, "offset", (to)->offset); \
4309
- add_assoc_bool(&element, "isdst", (to)->is_dst); \
4310
- add_assoc_string(&element, "abbr", (to)->abbr); \
4311
- add_next_index_zval(return_value, &element);
4313
+ if (ts > timestamp_added_last) { \
4314
+ array_init(&element); \
4315
+ add_assoc_long(&element, "ts", ts); \
4316
+ add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4317
+ add_assoc_long(&element, "offset", (to)->offset); \
4318
+ add_assoc_bool(&element, "isdst", (to)->is_dst); \
4319
+ add_assoc_string(&element, "abbr", (to)->abbr); \
4320
+ add_next_index_zval(return_value, &element); \
4321
+ timestamp_added_last = ts; \
4322
+ }
4312
4323
4313
4324
#define add_last () add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
4314
4325
0 commit comments