Path: blob/main/contrib/llvm-project/libcxx/include/__chrono/tzdb.h
35262 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html1011#ifndef _LIBCPP___CHRONO_TZDB_H12#define _LIBCPP___CHRONO_TZDB_H1314#include <version>15// Enable the contents of the header only when libc++ was built with experimental features enabled.16#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)1718# include <__algorithm/ranges_lower_bound.h>19# include <__chrono/leap_second.h>20# include <__chrono/time_zone.h>21# include <__chrono/time_zone_link.h>22# include <__config>23# include <string>24# include <vector>2526# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27# pragma GCC system_header28# endif2930_LIBCPP_PUSH_MACROS31# include <__undef_macros>3233_LIBCPP_BEGIN_NAMESPACE_STD3435# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \36!defined(_LIBCPP_HAS_NO_LOCALIZATION)3738namespace chrono {3940struct tzdb {41string version;42vector<time_zone> zones;43vector<time_zone_link> links;4445vector<leap_second> leap_seconds;4647[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* __locate_zone(string_view __name) const {48if (const time_zone* __result = __find_in_zone(__name))49return __result;5051if (auto __it = ranges::lower_bound(links, __name, {}, &time_zone_link::name);52__it != links.end() && __it->name() == __name)53if (const time_zone* __result = __find_in_zone(__it->target()))54return __result;5556return nullptr;57}5859[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* locate_zone(string_view __name) const {60if (const time_zone* __result = __locate_zone(__name))61return __result;6263std::__throw_runtime_error("tzdb: requested time zone not found");64}6566[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI const time_zone* current_zone() const {67return __current_zone();68}6970private:71_LIBCPP_HIDE_FROM_ABI const time_zone* __find_in_zone(string_view __name) const noexcept {72if (auto __it = ranges::lower_bound(zones, __name, {}, &time_zone::name);73__it != zones.end() && __it->name() == __name)74return std::addressof(*__it);7576return nullptr;77}7879[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const time_zone* __current_zone() const;80};8182} // namespace chrono8384# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)85// && !defined(_LIBCPP_HAS_NO_LOCALIZATION)8687_LIBCPP_END_NAMESPACE_STD8889_LIBCPP_POP_MACROS9091#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)9293#endif // _LIBCPP___CHRONO_TZDB_H949596