diff options
author | Abseil Team <absl-team@google.com> | 2022-08-16 09:50:44 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-08-16 09:51:53 -0700 |
commit | fa69b19a4e1c96943fad67fbe99ce77cb23f2e7e (patch) | |
tree | e37c7d268196d54e3e71b823660982ab4eb3b508 /absl/time/internal/cctz/src/time_zone_info.cc | |
parent | 59cba2b50dd689010f338c63db95ca164f195798 (diff) |
Import of CCTZ from GitHub.
PiperOrigin-RevId: 467950116
Change-Id: Iccb0c80c93f1064a82a5537d4519b041609cddd6
Diffstat (limited to 'absl/time/internal/cctz/src/time_zone_info.cc')
-rw-r--r-- | absl/time/internal/cctz/src/time_zone_info.cc | 16 |
1 files changed, 16 insertions, 0 deletions
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; |