diff options
Diffstat (limited to 'absl/time/internal/cctz/src/time_zone_info.h')
-rw-r--r-- | absl/time/internal/cctz/src/time_zone_info.h | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/absl/time/internal/cctz/src/time_zone_info.h b/absl/time/internal/cctz/src/time_zone_info.h index 2467ff55..689df6f9 100644 --- a/absl/time/internal/cctz/src/time_zone_info.h +++ b/absl/time/internal/cctz/src/time_zone_info.h @@ -18,6 +18,7 @@ #include <atomic> #include <cstddef> #include <cstdint> +#include <memory> #include <string> #include <vector> @@ -64,12 +65,9 @@ struct TransitionType { // A time zone backed by the IANA Time Zone Database (zoneinfo). class TimeZoneInfo : public TimeZoneIf { public: - TimeZoneInfo() = default; - TimeZoneInfo(const TimeZoneInfo&) = delete; - TimeZoneInfo& operator=(const TimeZoneInfo&) = delete; - - // Loads the zoneinfo for the given name, returning true if successful. - bool Load(const std::string& name); + // Factories. + static std::unique_ptr<TimeZoneInfo> UTC(); // never fails + static std::unique_ptr<TimeZoneInfo> Make(const std::string& name); // TimeZoneIf implementations. time_zone::absolute_lookup BreakTime( @@ -83,17 +81,9 @@ class TimeZoneInfo : public TimeZoneIf { std::string Description() const override; private: - struct Header { // counts of: - std::size_t timecnt; // transition times - std::size_t typecnt; // transition types - std::size_t charcnt; // zone abbreviation characters - std::size_t leapcnt; // leap seconds (we expect none) - std::size_t ttisstdcnt; // UTC/local indicators (unused) - std::size_t ttisutcnt; // standard/wall indicators (unused) - - bool Build(const tzhead& tzh); - std::size_t DataLength(std::size_t time_len) const; - }; + TimeZoneInfo() = default; + TimeZoneInfo(const TimeZoneInfo&) = delete; + TimeZoneInfo& operator=(const TimeZoneInfo&) = delete; bool GetTransitionType(std::int_fast32_t utc_offset, bool is_dst, const std::string& abbr, std::uint_least8_t* index); @@ -102,6 +92,7 @@ class TimeZoneInfo : public TimeZoneIf { bool ExtendTransitions(); bool ResetToBuiltinUTC(const seconds& offset); + bool Load(const std::string& name); bool Load(ZoneInfoSource* zip); // Helpers for BreakTime() and MakeTime(). |