summaryrefslogtreecommitdiff
path: root/absl/time/internal/cctz
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-08-01 10:39:31 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-08-01 10:40:19 -0700
commitf6acd471e2b9063e9d56a6e7867023d87649a03c (patch)
treebfd4eb67e7f18397383bd2f59d9ce48d72278c1d /absl/time/internal/cctz
parenta4771dbd8a34980a6b41c595c1c07d1d0a1e1e2c (diff)
Import of CCTZ from GitHub.
PiperOrigin-RevId: 552848883 Change-Id: Ibcf4b59e2ab671d8dd8fddcbc9d74d4c8cd3f0ff
Diffstat (limited to 'absl/time/internal/cctz')
-rw-r--r--absl/time/internal/cctz/src/time_zone_info.cc14
-rw-r--r--absl/time/internal/cctz/src/time_zone_lookup_test.cc1
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",