diff --git a/include/date/tz.h b/include/date/tz.h index 3195461..59677b1 100644 --- a/include/date/tz.h +++ b/include/date/tz.h @@ -1163,7 +1163,7 @@ struct timezone_mapping #endif // _WIN32 -struct TZ_DB +struct tzdb { std::string version = "unknown"; std::vector zones; @@ -1179,14 +1179,14 @@ struct TZ_DB #ifdef _WIN32 std::vector mappings; #endif - TZ_DB* next = nullptr; + tzdb* next = nullptr; - TZ_DB() = default; + tzdb() = default; #if !defined(_MSC_VER) || (_MSC_VER >= 1900) - TZ_DB(TZ_DB&&) = default; - TZ_DB& operator=(TZ_DB&&) = default; + tzdb(tzdb&&) = default; + tzdb& operator=(tzdb&&) = default; #else // defined(_MSC_VER) && (_MSC_VER < 1900) - TZ_DB(TZ_DB&& src) + tzdb(tzdb&& src) : version(std::move(src.version)) , zones(std::move(src.zones)) , links(std::move(src.links)) @@ -1195,7 +1195,7 @@ struct TZ_DB , mappings(std::move(src.mappings)) {} - TZ_DB& operator=(TZ_DB&& src) + tzdb& operator=(tzdb&& src) { version = std::move(src.version); zones = std::move(src.zones); @@ -1215,22 +1215,24 @@ struct TZ_DB const time_zone* current_zone() const; }; -DATE_API std::ostream& -operator<<(std::ostream& os, const TZ_DB& db); +using TZ_DB = tzdb; -DATE_API const TZ_DB& get_tzdb(); +DATE_API std::ostream& +operator<<(std::ostream& os, const tzdb& db); + +DATE_API const tzdb& get_tzdb(); class tzdb_list { - std::atomic head_{nullptr}; + std::atomic head_{nullptr}; public: ~tzdb_list(); tzdb_list() = default; tzdb_list(tzdb_list&& x) noexcept; - const TZ_DB& front() const noexcept {return *head_;} - TZ_DB& front() noexcept {return *head_;} + const tzdb& front() const noexcept {return *head_;} + tzdb& front() noexcept {return *head_;} class const_iterator; @@ -1244,19 +1246,19 @@ public: struct undocumented_helper; private: - void push_front(TZ_DB* tzdb) noexcept; + void push_front(tzdb* tzdb) noexcept; }; class tzdb_list::const_iterator { - TZ_DB* p_ = nullptr; + tzdb* p_ = nullptr; - explicit const_iterator(TZ_DB* p) noexcept : p_{p} {} + explicit const_iterator(tzdb* p) noexcept : p_{p} {} public: const_iterator() = default; using iterator_category = std::forward_iterator_tag; - using value_type = TZ_DB; + using value_type = tzdb; using reference = const value_type&; using pointer = const value_type*; using difference_type = std::ptrdiff_t; @@ -1312,8 +1314,8 @@ DATE_API tzdb_list& get_tzdb_list(); #if !USE_OS_TZDB -DATE_API const TZ_DB& reload_tzdb(); -DATE_API void set_install(const std::string& install); +DATE_API const tzdb& reload_tzdb(); +DATE_API void set_install(const std::string& install); #endif // !USE_OS_TZDB diff --git a/src/tz.cpp b/src/tz.cpp index 7773372..fd7e97a 100644 --- a/src/tz.cpp +++ b/src/tz.cpp @@ -359,11 +359,11 @@ struct undocumented {explicit undocumented() = default;}; static_assert(min_year <= max_year, "Configuration error"); #endif -static std::unique_ptr init_tzdb(); +static std::unique_ptr init_tzdb(); tzdb_list::~tzdb_list() { - const TZ_DB* ptr = head_; + const tzdb* ptr = head_; head_ = nullptr; while (ptr != nullptr) { @@ -379,7 +379,7 @@ tzdb_list::tzdb_list(tzdb_list&& x) noexcept } void -tzdb_list::push_front(TZ_DB* tzdb) noexcept +tzdb_list::push_front(tzdb* tzdb) noexcept { tzdb->next = head_; head_ = tzdb; @@ -396,7 +396,7 @@ tzdb_list::erase_after(const_iterator p) noexcept struct tzdb_list::undocumented_helper { - static void push_front(tzdb_list& db_list, TZ_DB* tzdb) noexcept + static void push_front(tzdb_list& db_list, tzdb* tzdb) noexcept { db_list.push_front(tzdb); } @@ -2573,10 +2573,10 @@ get_version() # endif static -std::unique_ptr +std::unique_ptr init_tzdb() { - std::unique_ptr db(new TZ_DB); + std::unique_ptr db(new tzdb); //Iterate through folders std::queue subfolders; @@ -3280,7 +3280,7 @@ get_version(const std::string& path) } static -std::unique_ptr +std::unique_ptr init_tzdb() { using namespace date; @@ -3288,7 +3288,7 @@ init_tzdb() const std::string path = install + folder_delimiter; std::string line; bool continue_zone = false; - std::unique_ptr db(new TZ_DB); + std::unique_ptr db(new tzdb); #if AUTO_DOWNLOAD if (!file_exists(install)) @@ -3405,7 +3405,7 @@ init_tzdb() return db; } -const TZ_DB& +const tzdb& reload_tzdb() { #if AUTO_DOWNLOAD @@ -3419,7 +3419,7 @@ reload_tzdb() #endif // !USE_OS_TZDB -const TZ_DB& +const tzdb& get_tzdb() { return get_tzdb_list().front(); @@ -3427,9 +3427,9 @@ get_tzdb() const time_zone* #if HAS_STRING_VIEW -TZ_DB::locate_zone(std::string_view tz_name) const +tzdb::locate_zone(std::string_view tz_name) const #else -TZ_DB::locate_zone(const std::string& tz_name) const +tzdb::locate_zone(const std::string& tz_name) const #endif { auto zi = std::lower_bound(zones.begin(), zones.end(), tz_name, @@ -3482,7 +3482,7 @@ locate_zone(const std::string& tz_name) #if USE_OS_TZDB std::ostream& -operator<<(std::ostream& os, const TZ_DB& db) +operator<<(std::ostream& os, const tzdb& db) { os << "Version: " << db.version << "\n\n"; for (const auto& x : db.zones) @@ -3498,7 +3498,7 @@ operator<<(std::ostream& os, const TZ_DB& db) #else // !USE_OS_TZDB std::ostream& -operator<<(std::ostream& os, const TZ_DB& db) +operator<<(std::ostream& os, const tzdb& db) { os << "Version: " << db.version << '\n'; std::string title("--------------------------------------------" @@ -3579,7 +3579,7 @@ getTimeZoneKeyName() } const time_zone* -TZ_DB::current_zone() const +tzdb::current_zone() const { std::string win_tzid = getTimeZoneKeyName(); std::string standard_tzid; @@ -3597,7 +3597,7 @@ TZ_DB::current_zone() const #else // !_WIN32 const time_zone* -TZ_DB::current_zone() const +tzdb::current_zone() const { // On some OS's a file called /etc/localtime may // exist and it may be either a real file