File indexing completed on 2025-01-18 09:27:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_
0016 #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_
0017
0018 #include <chrono>
0019 #include <cstdint>
0020 #include <memory>
0021 #include <string>
0022
0023 #include "absl/base/config.h"
0024 #include "absl/time/internal/cctz/include/cctz/civil_time.h"
0025 #include "absl/time/internal/cctz/include/cctz/time_zone.h"
0026
0027 namespace absl {
0028 ABSL_NAMESPACE_BEGIN
0029 namespace time_internal {
0030 namespace cctz {
0031
0032
0033
0034 class TimeZoneIf {
0035 public:
0036
0037 static std::unique_ptr<TimeZoneIf> UTC();
0038 static std::unique_ptr<TimeZoneIf> Make(const std::string& name);
0039
0040 virtual ~TimeZoneIf();
0041
0042 virtual time_zone::absolute_lookup BreakTime(
0043 const time_point<seconds>& tp) const = 0;
0044 virtual time_zone::civil_lookup MakeTime(const civil_second& cs) const = 0;
0045
0046 virtual bool NextTransition(const time_point<seconds>& tp,
0047 time_zone::civil_transition* trans) const = 0;
0048 virtual bool PrevTransition(const time_point<seconds>& tp,
0049 time_zone::civil_transition* trans) const = 0;
0050
0051 virtual std::string Version() const = 0;
0052 virtual std::string Description() const = 0;
0053
0054 protected:
0055 TimeZoneIf() = default;
0056 TimeZoneIf(const TimeZoneIf&) = delete;
0057 TimeZoneIf& operator=(const TimeZoneIf&) = delete;
0058 };
0059
0060
0061
0062
0063
0064 inline std::int_fast64_t ToUnixSeconds(const time_point<seconds>& tp) {
0065 return (tp - std::chrono::time_point_cast<seconds>(
0066 std::chrono::system_clock::from_time_t(0)))
0067 .count();
0068 }
0069 inline time_point<seconds> FromUnixSeconds(std::int_fast64_t t) {
0070 return std::chrono::time_point_cast<seconds>(
0071 std::chrono::system_clock::from_time_t(0)) +
0072 seconds(t);
0073 }
0074
0075 }
0076 }
0077 ABSL_NAMESPACE_END
0078 }
0079
0080 #endif