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-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10// UNSUPPORTED: no-filesystem, no-localization, no-tzdb
11
12// XFAIL: libcpp-has-no-experimental-tzdb
13// XFAIL: availability-tzdb-missing
14
15// <chrono>
16//
17// class utc_clock;
18
19// static time_point now();
20
21#include <chrono>
22#include <concepts>
23#include <cassert>
24
25int main(int, const char**) {
26 using clock = std::chrono::utc_clock;
27 std::same_as<clock::time_point> decltype(auto) t = clock::now();
28
29 assert(t >= clock::time_point::min());
30 assert(t <= clock::time_point::max());
31
32 auto t2 = clock::now();
33 assert(t2 - t >= std::chrono::seconds(0));
34 // This may fail if the tests takes a long time to complete.
35 assert(t2 - t < std::chrono::seconds(42));
36
37 return 0;
38}
39

source code of libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/now.pass.cpp