Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_
00016 #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_
00017
00018 #include <chrono>
00019 #include <cstdint>
00020 #include <memory>
00021 #include <string>
00022
00023 #include "absl/time/internal/cctz/include/cctz/civil_time.h"
00024 #include "absl/time/internal/cctz/include/cctz/time_zone.h"
00025
00026 namespace absl {
00027 namespace time_internal {
00028 namespace cctz {
00029
00030
00031
00032 class TimeZoneIf {
00033 public:
00034
00035 static std::unique_ptr<TimeZoneIf> Load(const std::string& name);
00036
00037 virtual ~TimeZoneIf();
00038
00039 virtual time_zone::absolute_lookup BreakTime(
00040 const time_point<seconds>& tp) const = 0;
00041 virtual time_zone::civil_lookup MakeTime(
00042 const civil_second& cs) const = 0;
00043
00044 virtual bool NextTransition(const time_point<seconds>& tp,
00045 time_zone::civil_transition* trans) const = 0;
00046 virtual bool PrevTransition(const time_point<seconds>& tp,
00047 time_zone::civil_transition* trans) const = 0;
00048
00049 virtual std::string Version() const = 0;
00050 virtual std::string Description() const = 0;
00051
00052 protected:
00053 TimeZoneIf() {}
00054 };
00055
00056
00057
00058
00059 inline std::int_fast64_t ToUnixSeconds(const time_point<seconds>& tp) {
00060 return (tp - std::chrono::time_point_cast<seconds>(
00061 std::chrono::system_clock::from_time_t(0))).count();
00062 }
00063 inline time_point<seconds> FromUnixSeconds(std::int_fast64_t t) {
00064 return std::chrono::time_point_cast<seconds>(
00065 std::chrono::system_clock::from_time_t(0)) + seconds(t);
00066 }
00067
00068 }
00069 }
00070 }
00071
00072 #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_