|
| 1 | +// -*- C++ -*- |
| 2 | +//===----------------------------------------------------------------------===// |
| 3 | +// |
| 4 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | +// See https://llvm.org/LICENSE.txt for license information. |
| 6 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | +// |
| 8 | +//===----------------------------------------------------------------------===// |
| 9 | + |
| 10 | +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html |
| 11 | + |
| 12 | +#ifndef _LIBCPP___CHRONO_ZONED_TIME_H |
| 13 | +#define _LIBCPP___CHRONO_ZONED_TIME_H |
| 14 | + |
| 15 | +#include <version> |
| 16 | +// Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | +#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) |
| 18 | + |
| 19 | +# include <__chrono/time_zone.h> |
| 20 | +# include <__chrono/tzdb_list.h> |
| 21 | +# include <__config> |
| 22 | +# include <__fwd/string_view.h> |
| 23 | + |
| 24 | +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | +# pragma GCC system_header |
| 26 | +# endif |
| 27 | + |
| 28 | +_LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | + |
| 30 | +# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ |
| 31 | + !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 32 | + |
| 33 | +namespace chrono { |
| 34 | + |
| 35 | +template <class> |
| 36 | +struct zoned_traits {}; |
| 37 | + |
| 38 | +template <> |
| 39 | +struct zoned_traits<const time_zone*> { |
| 40 | + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static const time_zone* default_zone() { return chrono::locate_zone("UTC"); } |
| 41 | + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static const time_zone* locate_zone(string_view __name) { |
| 42 | + return chrono::locate_zone(__name); |
| 43 | + } |
| 44 | +}; |
| 45 | + |
| 46 | +} // namespace chrono |
| 47 | + |
| 48 | +# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) |
| 49 | + // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 50 | + |
| 51 | +_LIBCPP_END_NAMESPACE_STD |
| 52 | + |
| 53 | +#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) |
| 54 | + |
| 55 | +#endif // _LIBCPP___CHRONO_ZONED_TIME_H |
0 commit comments