From f6acd471e2b9063e9d56a6e7867023d87649a03c Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 1 Aug 2023 10:39:31 -0700 Subject: Import of CCTZ from GitHub. PiperOrigin-RevId: 552848883 Change-Id: Ibcf4b59e2ab671d8dd8fddcbc9d74d4c8cd3f0ff --- absl/time/internal/cctz/src/time_zone_info.cc | 14 ++++++++------ absl/time/internal/cctz/src/time_zone_lookup_test.cc | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc index a3be6558..f46198ff 100644 --- a/absl/time/internal/cctz/src/time_zone_info.cc +++ b/absl/time/internal/cctz/src/time_zone_info.cc @@ -338,11 +338,13 @@ bool TimeZoneInfo::ExtendTransitions() { return EquivTransitions(transitions_.back().type_index, dst_ti); } - // Extend the transitions for an additional 400 years using the - // future specification. Years beyond those can be handled by - // mapping back to a cycle-equivalent year within that range. - // We may need two additional transitions for the current year. - transitions_.reserve(transitions_.size() + 400 * 2 + 2); + // Extend the transitions for an additional 401 years using the future + // specification. Years beyond those can be handled by mapping back to + // a cycle-equivalent year within that range. Note that we need 401 + // (well, at least the first transition in the 401st year) so that the + // end of the 400th year is mapped back to an extended year. And first + // we may also need two additional transitions for the current year. + transitions_.reserve(transitions_.size() + 2 + 401 * 2); extended_ = true; const Transition& last(transitions_.back()); @@ -356,7 +358,7 @@ bool TimeZoneInfo::ExtendTransitions() { Transition dst = {0, dst_ti, civil_second(), civil_second()}; Transition std = {0, std_ti, civil_second(), civil_second()}; - for (const year_t limit = last_year_ + 400;; ++last_year_) { + for (const year_t limit = last_year_ + 401;; ++last_year_) { auto dst_trans_off = TransOffset(leap_year, jan1_weekday, posix.dst_start); auto std_trans_off = TransOffset(leap_year, jan1_weekday, posix.dst_end); dst.unix_time = jan1_time + dst_trans_off - posix.std_offset; diff --git a/absl/time/internal/cctz/src/time_zone_lookup_test.cc b/absl/time/internal/cctz/src/time_zone_lookup_test.cc index fc659266..4884c32e 100644 --- a/absl/time/internal/cctz/src/time_zone_lookup_test.cc +++ b/absl/time/internal/cctz/src/time_zone_lookup_test.cc @@ -135,6 +135,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan", "America/Cayman", "America/Chicago", "America/Chihuahua", + "America/Ciudad_Juarez", "America/Coral_Harbour", "America/Cordoba", "America/Costa_Rica", -- cgit v1.2.3