diff options
Diffstat (limited to 'absl/time/internal/cctz/src')
-rw-r--r-- | absl/time/internal/cctz/src/cctz_benchmark.cc | 2 | ||||
-rw-r--r-- | absl/time/internal/cctz/src/time_zone_info.cc | 16 | ||||
-rw-r--r-- | absl/time/internal/cctz/src/time_zone_lookup_test.cc | 5 |
3 files changed, 22 insertions, 1 deletions
diff --git a/absl/time/internal/cctz/src/cctz_benchmark.cc b/absl/time/internal/cctz/src/cctz_benchmark.cc index 6770ad6b..c64f3801 100644 --- a/absl/time/internal/cctz/src/cctz_benchmark.cc +++ b/absl/time/internal/cctz/src/cctz_benchmark.cc @@ -554,6 +554,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan", "Europe/Kaliningrad", "Europe/Kiev", "Europe/Kirov", + "Europe/Kyiv", "Europe/Lisbon", "Europe/Ljubljana", "Europe/London", @@ -593,6 +594,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan", "Europe/Zagreb", "Europe/Zaporozhye", "Europe/Zurich", + "Factory", "GB", "GB-Eire", "GMT", diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc index 4f175d95..a2617d5e 100644 --- a/absl/time/internal/cctz/src/time_zone_info.cc +++ b/absl/time/internal/cctz/src/time_zone_info.cc @@ -134,6 +134,21 @@ std::int_fast64_t Decode64(const char* cp) { return static_cast<std::int_fast64_t>(v - s64maxU - 1) - s64max - 1; } +// Does the rule for future transitions call for year-round daylight time? +// See tz/zic.c:stringzone() for the details on how such rules are encoded. +bool AllYearDST(const PosixTimeZone& posix) { + if (posix.dst_start.date.fmt != PosixTransition::N) return false; + if (posix.dst_start.date.n.day != 0) return false; + if (posix.dst_start.time.offset != 0) return false; + + if (posix.dst_end.date.fmt != PosixTransition::J) return false; + if (posix.dst_end.date.j.day != kDaysPerYear[0]) return false; + const auto offset = posix.std_offset - posix.dst_offset; + if (posix.dst_end.time.offset + offset != kSecsPerDay) return false; + + return true; +} + // Generate a year-relative offset for a PosixTransition. std::int_fast64_t TransOffset(bool leap_year, int jan1_weekday, const PosixTransition& pt) { @@ -334,6 +349,7 @@ bool TimeZoneInfo::ExtendTransitions() { PosixTimeZone posix; if (!ParsePosixSpec(future_spec_, &posix)) return false; + if (AllYearDST(posix)) return true; // last transition still prevails // Find transition type for the future std specification. std::uint_least8_t std_ti; 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 27a53c5c..ab461f04 100644 --- a/absl/time/internal/cctz/src/time_zone_lookup_test.cc +++ b/absl/time/internal/cctz/src/time_zone_lookup_test.cc @@ -489,6 +489,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan", "Europe/Kaliningrad", "Europe/Kiev", "Europe/Kirov", + "Europe/Kyiv", "Europe/Lisbon", "Europe/Ljubljana", "Europe/London", @@ -528,6 +529,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan", "Europe/Zagreb", "Europe/Zaporozhye", "Europe/Zurich", + "Factory", "GB", "GB-Eire", "GMT", @@ -1188,11 +1190,12 @@ TEST(PrevTransition, AmericaNewYork) { TEST(NextTransition, Scan) { for (const char* const* np = kTimeZoneNames; *np != nullptr; ++np) { + SCOPED_TRACE(testing::Message() << "In " << *np); time_zone tz; + // EXPECT_TRUE(load_time_zone(*np, &tz)); if (!load_time_zone(*np, &tz)) { continue; // tolerate kTimeZoneNames/zoneinfo skew } - SCOPED_TRACE(testing::Message() << "In " << *np); auto tp = time_point<absl::time_internal::cctz::seconds>::min(); time_zone::civil_transition trans; |