Commit f6acd471 by Abseil Team Committed by Copybara-Service

Import of CCTZ from GitHub.

PiperOrigin-RevId: 552848883
Change-Id: Ibcf4b59e2ab671d8dd8fddcbc9d74d4c8cd3f0ff
parent a4771dbd
...@@ -338,11 +338,13 @@ bool TimeZoneInfo::ExtendTransitions() { ...@@ -338,11 +338,13 @@ bool TimeZoneInfo::ExtendTransitions() {
return EquivTransitions(transitions_.back().type_index, dst_ti); return EquivTransitions(transitions_.back().type_index, dst_ti);
} }
// Extend the transitions for an additional 400 years using the // Extend the transitions for an additional 401 years using the future
// future specification. Years beyond those can be handled by // specification. Years beyond those can be handled by mapping back to
// mapping back to a cycle-equivalent year within that range. // a cycle-equivalent year within that range. Note that we need 401
// We may need two additional transitions for the current year. // (well, at least the first transition in the 401st year) so that the
transitions_.reserve(transitions_.size() + 400 * 2 + 2); // 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; extended_ = true;
const Transition& last(transitions_.back()); const Transition& last(transitions_.back());
...@@ -356,7 +358,7 @@ bool TimeZoneInfo::ExtendTransitions() { ...@@ -356,7 +358,7 @@ bool TimeZoneInfo::ExtendTransitions() {
Transition dst = {0, dst_ti, civil_second(), civil_second()}; Transition dst = {0, dst_ti, civil_second(), civil_second()};
Transition std = {0, std_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 dst_trans_off = TransOffset(leap_year, jan1_weekday, posix.dst_start);
auto std_trans_off = TransOffset(leap_year, jan1_weekday, posix.dst_end); auto std_trans_off = TransOffset(leap_year, jan1_weekday, posix.dst_end);
dst.unix_time = jan1_time + dst_trans_off - posix.std_offset; dst.unix_time = jan1_time + dst_trans_off - posix.std_offset;
......
...@@ -135,6 +135,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan", ...@@ -135,6 +135,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
"America/Cayman", "America/Cayman",
"America/Chicago", "America/Chicago",
"America/Chihuahua", "America/Chihuahua",
"America/Ciudad_Juarez",
"America/Coral_Harbour", "America/Coral_Harbour",
"America/Cordoba", "America/Cordoba",
"America/Costa_Rica", "America/Costa_Rica",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment