19 #include <unordered_map> 25 namespace time_internal {
31 using TimeZoneImplByName =
32 std::unordered_map<std::string, const time_zone::Impl*>;
33 TimeZoneImplByName* time_zone_map =
nullptr;
36 std::mutex time_zone_mutex;
48 auto offset = seconds::zero();
57 std::lock_guard<std::mutex> lock(time_zone_mutex);
58 if (time_zone_map !=
nullptr) {
59 TimeZoneImplByName::const_iterator itr = time_zone_map->find(name);
60 if (itr != time_zone_map->end()) {
62 return itr->second != utc_impl;
68 std::lock_guard<std::mutex> lock(time_zone_mutex);
69 if (time_zone_map ==
nullptr) time_zone_map =
new TimeZoneImplByName;
70 const Impl*& impl = (*time_zone_map)[
name];
71 if (impl ==
nullptr) {
75 if (new_impl->
zone_ ==
nullptr) {
83 return impl != utc_impl;
87 std::lock_guard<std::mutex> lock(time_zone_mutex);
88 if (time_zone_map !=
nullptr) {
91 time_zone_map->clear();
98 static Impl* utc_impl = [] {
static bool LoadTimeZone(const std::string &name, time_zone *tz)
Impl(const std::string &name)
std::unique_ptr< TimeZoneIf > zone_
static void ClearTimeZoneMapTestOnly()
static const Impl * UTCImpl()
static std::unique_ptr< TimeZoneIf > Load(const std::string &name)
bool FixedOffsetFromName(const std::string &name, seconds *offset)