1 //===----------------------------------------------------------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: no-filesystem, no-localization, no-tzdb
12 // XFAIL: libcpp-has-no-experimental-tzdb
13 // XFAIL: availability-tzdb-missing
17 // template<class Duration, class TimeZonePtr = const time_zone*>
20 // explicit zoned_time(TimeZonePtr z);
26 #include "../test_offset_time_zone.h"
28 // Verify the results of the constructed object.
29 int main(int, char**) {
31 using ptr
= const std::chrono::time_zone
*;
32 static_assert(std::constructible_from
<std::chrono::zoned_time
<std::chrono::seconds
, ptr
>, ptr
>);
33 static_assert(!std::convertible_to
<ptr
, std::chrono::zoned_time
<std::chrono::seconds
, ptr
>>);
35 ptr tz
= std::chrono::locate_zone("UTC");
36 std::chrono::zoned_time
<std::chrono::seconds
> zt
{tz
};
38 assert(zt
.get_time_zone() == tz
);
39 assert(zt
.get_sys_time() == std::chrono::sys_seconds
{});
43 using ptr
= offset_time_zone
<offset_time_zone_flags::none
>;
44 static_assert(std::constructible_from
<std::chrono::zoned_time
<std::chrono::seconds
, ptr
>, ptr
>);
45 static_assert(!std::convertible_to
<ptr
, std::chrono::zoned_time
<std::chrono::seconds
, ptr
>>);
48 std::chrono::zoned_time
<std::chrono::seconds
, ptr
> zt
{tz
};
50 assert(zt
.get_time_zone().offset() == tz
.offset());
51 assert(zt
.get_sys_time() == std::chrono::sys_seconds
{});
54 using ptr
= offset_time_zone
<offset_time_zone_flags::has_default_zone
>;
55 static_assert(std::constructible_from
<std::chrono::zoned_time
<std::chrono::seconds
, ptr
>, ptr
>);
56 static_assert(!std::convertible_to
<ptr
, std::chrono::zoned_time
<std::chrono::seconds
, ptr
>>);
59 std::chrono::zoned_time
<std::chrono::seconds
, ptr
> zt
{tz
};
61 assert(zt
.get_time_zone().offset() == tz
.offset());
62 assert(zt
.get_sys_time() == std::chrono::sys_seconds
{});
65 using ptr
= offset_time_zone
<offset_time_zone_flags::has_locate_zone
>;
66 static_assert(std::constructible_from
<std::chrono::zoned_time
<std::chrono::seconds
, ptr
>, ptr
>);
67 static_assert(!std::convertible_to
<ptr
, std::chrono::zoned_time
<std::chrono::seconds
, ptr
>>);
70 std::chrono::zoned_time
<std::chrono::seconds
, ptr
> zt
{tz
};
72 assert(zt
.get_time_zone().offset() == tz
.offset());
73 assert(zt
.get_sys_time() == std::chrono::sys_seconds
{});
76 using ptr
= offset_time_zone
<offset_time_zone_flags::both
>;
77 static_assert(std::constructible_from
<std::chrono::zoned_time
<std::chrono::seconds
, ptr
>, ptr
>);
78 static_assert(!std::convertible_to
<ptr
, std::chrono::zoned_time
<std::chrono::seconds
, ptr
>>);
81 std::chrono::zoned_time
<std::chrono::seconds
, ptr
> zt
{tz
};
83 assert(zt
.get_time_zone().offset() == tz
.offset());
84 assert(zt
.get_sys_time() == std::chrono::sys_seconds
{});