67 lines · cpp
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//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710// UNSUPPORTED: no-filesystem, no-localization, no-tzdb11 12// XFAIL: libcpp-has-no-experimental-tzdb13// XFAIL: availability-tzdb-missing14 15// <chrono>16 17// template<class Duration, class TimeZonePtr = const time_zone*>18// class zoned_time;19//20// zoned_time();21 22#include <chrono>23#include <concepts>24#include <type_traits>25 26#include "../test_offset_time_zone.h"27 28// Verify the results of the default constructed object,29// and whether the constructor's constraints are satisfied.30int main(int, char**) {31 {32 static_assert(std::default_initializable<std::chrono::zoned_time<std::chrono::seconds>>);33 std::chrono::zoned_time<std::chrono::seconds> zt;34 assert(zt.get_time_zone() == std::chrono::locate_zone("UTC"));35 assert(zt.get_sys_time() == std::chrono::sys_seconds{});36 }37 38 static_assert(!std::default_initializable<39 std::chrono::zoned_time<std::chrono::seconds, offset_time_zone<offset_time_zone_flags::none>>>);40 41 {42 using type = offset_time_zone<offset_time_zone_flags::has_default_zone>;43 static_assert(std::default_initializable<std::chrono::zoned_time<std::chrono::seconds, type>>);44 45 std::chrono::zoned_time<std::chrono::seconds, type> zt;46 47 assert(zt.get_time_zone().offset() == std::chrono::seconds{0});48 assert(zt.get_sys_time() == std::chrono::sys_seconds{});49 }50 51 static_assert(52 !std::default_initializable<53 std::chrono::zoned_time<std::chrono::seconds, offset_time_zone<offset_time_zone_flags::has_locate_zone>>>);54 55 {56 using type = offset_time_zone<offset_time_zone_flags::both>;57 static_assert(std::default_initializable<std::chrono::zoned_time<std::chrono::seconds, type>>);58 59 std::chrono::zoned_time<std::chrono::seconds, type> zt;60 61 assert(zt.get_time_zone().offset() == std::chrono::seconds{0});62 assert(zt.get_sys_time() == std::chrono::sys_seconds{});63 }64 65 return 0;66}67