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// template<class Duration, class TimeZonePtr = const time_zone*>
18// class zoned_time;
19//
20// TimeZonePtr get_time_zone() const;
21
22#include <chrono>
23#include <cassert>
24#include <concepts>
25
26#include "../test_offset_time_zone.h"
27
28int main(int, char**) {
29 {
30 const std::chrono::time_zone* tz = std::chrono::locate_zone("UTC");
31 std::chrono::zoned_time<std::chrono::seconds> zt{tz};
32
33 std::same_as<const std::chrono::time_zone*> decltype(auto) ptr = zt.get_time_zone();
34 assert(ptr = tz);
35 }
36
37 {
38 int tz = 0;
39 std::chrono::zoned_time<std::chrono::seconds, int*> zt{&tz};
40
41 std::same_as<int*> decltype(auto) ptr = zt.get_time_zone();
42 assert(ptr = &tz);
43 }
44
45 {
46 int tz = 0;
47 const std::chrono::zoned_time<std::chrono::seconds, int*> zt{&tz};
48
49 std::same_as<int*> decltype(auto) ptr = zt.get_time_zone();
50 assert(ptr = &tz);
51 }
52
53 return 0;
54}
55

source code of libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_time_zone.pass.cpp