File indexing completed on 2026-05-03 08:13:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef _LIBCPP___CXX03___CHRONO_TZDB_H
0013 #define _LIBCPP___CXX03___CHRONO_TZDB_H
0014
0015 #include <__cxx03/version>
0016
0017 #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
0018
0019 # include <__cxx03/__algorithm/ranges_lower_bound.h>
0020 # include <__cxx03/__chrono/leap_second.h>
0021 # include <__cxx03/__chrono/time_zone.h>
0022 # include <__cxx03/__chrono/time_zone_link.h>
0023 # include <__cxx03/__config>
0024 # include <__cxx03/string>
0025 # include <__cxx03/vector>
0026
0027 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0028 # pragma GCC system_header
0029 # endif
0030
0031 _LIBCPP_PUSH_MACROS
0032 # include <__cxx03/__undef_macros>
0033
0034 _LIBCPP_BEGIN_NAMESPACE_STD
0035
0036 # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
0037 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
0038
0039 namespace chrono {
0040
0041 struct tzdb {
0042 string version;
0043 vector<time_zone> zones;
0044 vector<time_zone_link> links;
0045
0046 vector<leap_second> leap_seconds;
0047
0048 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* __locate_zone(string_view __name) const {
0049 if (const time_zone* __result = __find_in_zone(__name))
0050 return __result;
0051
0052 if (auto __it = ranges::lower_bound(links, __name, {}, &time_zone_link::name);
0053 __it != links.end() && __it->name() == __name)
0054 if (const time_zone* __result = __find_in_zone(__it->target()))
0055 return __result;
0056
0057 return nullptr;
0058 }
0059
0060 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* locate_zone(string_view __name) const {
0061 if (const time_zone* __result = __locate_zone(__name))
0062 return __result;
0063
0064 std::__throw_runtime_error("tzdb: requested time zone not found");
0065 }
0066
0067 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI const time_zone* current_zone() const {
0068 return __current_zone();
0069 }
0070
0071 private:
0072 _LIBCPP_HIDE_FROM_ABI const time_zone* __find_in_zone(string_view __name) const noexcept {
0073 if (auto __it = ranges::lower_bound(zones, __name, {}, &time_zone::name);
0074 __it != zones.end() && __it->name() == __name)
0075 return std::addressof(*__it);
0076
0077 return nullptr;
0078 }
0079
0080 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const time_zone* __current_zone() const;
0081 };
0082
0083 }
0084
0085 # endif
0086
0087
0088 _LIBCPP_END_NAMESPACE_STD
0089
0090 _LIBCPP_POP_MACROS
0091
0092 #endif
0093
0094 #endif