xref: /aosp_15_r20/external/libcxx/include/chrono (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===---------------------------- chrono ----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CHRONO
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_CHRONO
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    chrono synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workernamespace std
18*58b9f456SAndroid Build Coastguard Worker{
19*58b9f456SAndroid Build Coastguard Workernamespace chrono
20*58b9f456SAndroid Build Coastguard Worker{
21*58b9f456SAndroid Build Coastguard Worker
22*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Rep, class Period>
23*58b9f456SAndroid Build Coastguard Workerconstexpr
24*58b9f456SAndroid Build Coastguard WorkerToDuration
25*58b9f456SAndroid Build Coastguard Workerduration_cast(const duration<Rep, Period>& fd);
26*58b9f456SAndroid Build Coastguard Worker
27*58b9f456SAndroid Build Coastguard Workertemplate <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
28*58b9f456SAndroid Build Coastguard Worker
29*58b9f456SAndroid Build Coastguard Workertemplate <class Rep> inline constexpr bool treat_as_floating_point_v
30*58b9f456SAndroid Build Coastguard Worker    = treat_as_floating_point<Rep>::value;                       // C++17
31*58b9f456SAndroid Build Coastguard Worker
32*58b9f456SAndroid Build Coastguard Workertemplate <class Rep>
33*58b9f456SAndroid Build Coastguard Workerstruct duration_values
34*58b9f456SAndroid Build Coastguard Worker{
35*58b9f456SAndroid Build Coastguard Workerpublic:
36*58b9f456SAndroid Build Coastguard Worker    static constexpr Rep zero(); // noexcept in C++20
37*58b9f456SAndroid Build Coastguard Worker    static constexpr Rep max();  // noexcept in C++20
38*58b9f456SAndroid Build Coastguard Worker    static constexpr Rep min();  // noexcept in C++20
39*58b9f456SAndroid Build Coastguard Worker};
40*58b9f456SAndroid Build Coastguard Worker
41*58b9f456SAndroid Build Coastguard Worker// duration
42*58b9f456SAndroid Build Coastguard Worker
43*58b9f456SAndroid Build Coastguard Workertemplate <class Rep, class Period = ratio<1>>
44*58b9f456SAndroid Build Coastguard Workerclass duration
45*58b9f456SAndroid Build Coastguard Worker{
46*58b9f456SAndroid Build Coastguard Worker    static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
47*58b9f456SAndroid Build Coastguard Worker    static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
48*58b9f456SAndroid Build Coastguard Worker    static_assert(Period::num > 0, "duration period must be positive");
49*58b9f456SAndroid Build Coastguard Workerpublic:
50*58b9f456SAndroid Build Coastguard Worker    typedef Rep rep;
51*58b9f456SAndroid Build Coastguard Worker    typedef typename _Period::type period;
52*58b9f456SAndroid Build Coastguard Worker
53*58b9f456SAndroid Build Coastguard Worker    constexpr duration() = default;
54*58b9f456SAndroid Build Coastguard Worker    template <class Rep2>
55*58b9f456SAndroid Build Coastguard Worker        constexpr explicit duration(const Rep2& r,
56*58b9f456SAndroid Build Coastguard Worker            typename enable_if
57*58b9f456SAndroid Build Coastguard Worker            <
58*58b9f456SAndroid Build Coastguard Worker               is_convertible<Rep2, rep>::value &&
59*58b9f456SAndroid Build Coastguard Worker               (treat_as_floating_point<rep>::value ||
60*58b9f456SAndroid Build Coastguard Worker               !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
61*58b9f456SAndroid Build Coastguard Worker            >::type* = 0);
62*58b9f456SAndroid Build Coastguard Worker
63*58b9f456SAndroid Build Coastguard Worker    // conversions
64*58b9f456SAndroid Build Coastguard Worker    template <class Rep2, class Period2>
65*58b9f456SAndroid Build Coastguard Worker        constexpr duration(const duration<Rep2, Period2>& d,
66*58b9f456SAndroid Build Coastguard Worker            typename enable_if
67*58b9f456SAndroid Build Coastguard Worker            <
68*58b9f456SAndroid Build Coastguard Worker                treat_as_floating_point<rep>::value ||
69*58b9f456SAndroid Build Coastguard Worker                ratio_divide<Period2, period>::type::den == 1
70*58b9f456SAndroid Build Coastguard Worker            >::type* = 0);
71*58b9f456SAndroid Build Coastguard Worker
72*58b9f456SAndroid Build Coastguard Worker    // observer
73*58b9f456SAndroid Build Coastguard Worker
74*58b9f456SAndroid Build Coastguard Worker    constexpr rep count() const;
75*58b9f456SAndroid Build Coastguard Worker
76*58b9f456SAndroid Build Coastguard Worker    // arithmetic
77*58b9f456SAndroid Build Coastguard Worker
78*58b9f456SAndroid Build Coastguard Worker    constexpr common_type<duration>::type  operator+() const;
79*58b9f456SAndroid Build Coastguard Worker    constexpr common_type<duration>::type  operator-() const;
80*58b9f456SAndroid Build Coastguard Worker    constexpr duration& operator++();    // constexpr in C++17
81*58b9f456SAndroid Build Coastguard Worker    constexpr duration  operator++(int); // constexpr in C++17
82*58b9f456SAndroid Build Coastguard Worker    constexpr duration& operator--();    // constexpr in C++17
83*58b9f456SAndroid Build Coastguard Worker    constexpr duration  operator--(int); // constexpr in C++17
84*58b9f456SAndroid Build Coastguard Worker
85*58b9f456SAndroid Build Coastguard Worker    constexpr duration& operator+=(const duration& d);  // constexpr in C++17
86*58b9f456SAndroid Build Coastguard Worker    constexpr duration& operator-=(const duration& d);  // constexpr in C++17
87*58b9f456SAndroid Build Coastguard Worker
88*58b9f456SAndroid Build Coastguard Worker    duration& operator*=(const rep& rhs);       // constexpr in C++17
89*58b9f456SAndroid Build Coastguard Worker    duration& operator/=(const rep& rhs);       // constexpr in C++17
90*58b9f456SAndroid Build Coastguard Worker    duration& operator%=(const rep& rhs);       // constexpr in C++17
91*58b9f456SAndroid Build Coastguard Worker    duration& operator%=(const duration& rhs);  // constexpr in C++17
92*58b9f456SAndroid Build Coastguard Worker
93*58b9f456SAndroid Build Coastguard Worker    // special values
94*58b9f456SAndroid Build Coastguard Worker
95*58b9f456SAndroid Build Coastguard Worker    static constexpr duration zero(); // noexcept in C++20
96*58b9f456SAndroid Build Coastguard Worker    static constexpr duration min();  // noexcept in C++20
97*58b9f456SAndroid Build Coastguard Worker    static constexpr duration max();  // noexcept in C++20
98*58b9f456SAndroid Build Coastguard Worker};
99*58b9f456SAndroid Build Coastguard Worker
100*58b9f456SAndroid Build Coastguard Workertypedef duration<long long,         nano> nanoseconds;
101*58b9f456SAndroid Build Coastguard Workertypedef duration<long long,        micro> microseconds;
102*58b9f456SAndroid Build Coastguard Workertypedef duration<long long,        milli> milliseconds;
103*58b9f456SAndroid Build Coastguard Workertypedef duration<long long              > seconds;
104*58b9f456SAndroid Build Coastguard Workertypedef duration<     long, ratio<  60> > minutes;
105*58b9f456SAndroid Build Coastguard Workertypedef duration<     long, ratio<3600> > hours;
106*58b9f456SAndroid Build Coastguard Worker
107*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration = typename Clock::duration>
108*58b9f456SAndroid Build Coastguard Workerclass time_point
109*58b9f456SAndroid Build Coastguard Worker{
110*58b9f456SAndroid Build Coastguard Workerpublic:
111*58b9f456SAndroid Build Coastguard Worker    typedef Clock                     clock;
112*58b9f456SAndroid Build Coastguard Worker    typedef Duration                  duration;
113*58b9f456SAndroid Build Coastguard Worker    typedef typename duration::rep    rep;
114*58b9f456SAndroid Build Coastguard Worker    typedef typename duration::period period;
115*58b9f456SAndroid Build Coastguard Workerprivate:
116*58b9f456SAndroid Build Coastguard Worker    duration d_;  // exposition only
117*58b9f456SAndroid Build Coastguard Worker
118*58b9f456SAndroid Build Coastguard Workerpublic:
119*58b9f456SAndroid Build Coastguard Worker    time_point();  // has value "epoch" // constexpr in C++14
120*58b9f456SAndroid Build Coastguard Worker    explicit time_point(const duration& d);  // same as time_point() + d // constexpr in C++14
121*58b9f456SAndroid Build Coastguard Worker
122*58b9f456SAndroid Build Coastguard Worker    // conversions
123*58b9f456SAndroid Build Coastguard Worker    template <class Duration2>
124*58b9f456SAndroid Build Coastguard Worker       time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
125*58b9f456SAndroid Build Coastguard Worker
126*58b9f456SAndroid Build Coastguard Worker    // observer
127*58b9f456SAndroid Build Coastguard Worker
128*58b9f456SAndroid Build Coastguard Worker    duration time_since_epoch() const; // constexpr in C++14
129*58b9f456SAndroid Build Coastguard Worker
130*58b9f456SAndroid Build Coastguard Worker    // arithmetic
131*58b9f456SAndroid Build Coastguard Worker
132*58b9f456SAndroid Build Coastguard Worker    time_point& operator+=(const duration& d); // constexpr in C++17
133*58b9f456SAndroid Build Coastguard Worker    time_point& operator-=(const duration& d); // constexpr in C++17
134*58b9f456SAndroid Build Coastguard Worker
135*58b9f456SAndroid Build Coastguard Worker    // special values
136*58b9f456SAndroid Build Coastguard Worker
137*58b9f456SAndroid Build Coastguard Worker    static constexpr time_point min();  // noexcept in C++20
138*58b9f456SAndroid Build Coastguard Worker    static constexpr time_point max();  // noexcept in C++20
139*58b9f456SAndroid Build Coastguard Worker};
140*58b9f456SAndroid Build Coastguard Worker
141*58b9f456SAndroid Build Coastguard Worker} // chrono
142*58b9f456SAndroid Build Coastguard Worker
143*58b9f456SAndroid Build Coastguard Worker// common_type traits
144*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
145*58b9f456SAndroid Build Coastguard Worker  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
146*58b9f456SAndroid Build Coastguard Worker
147*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
148*58b9f456SAndroid Build Coastguard Worker  struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
149*58b9f456SAndroid Build Coastguard Worker
150*58b9f456SAndroid Build Coastguard Workernamespace chrono {
151*58b9f456SAndroid Build Coastguard Worker
152*58b9f456SAndroid Build Coastguard Worker
153*58b9f456SAndroid Build Coastguard Workertemplate<class T> struct is_clock;  // C++20
154*58b9f456SAndroid Build Coastguard Workertemplate<class T> inline constexpr bool is_clock_v = is_clock<T>::value;   // C++20
155*58b9f456SAndroid Build Coastguard Worker
156*58b9f456SAndroid Build Coastguard Worker
157*58b9f456SAndroid Build Coastguard Worker// duration arithmetic
158*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
159*58b9f456SAndroid Build Coastguard Worker  constexpr
160*58b9f456SAndroid Build Coastguard Worker  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
161*58b9f456SAndroid Build Coastguard Worker  operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
162*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
163*58b9f456SAndroid Build Coastguard Worker  constexpr
164*58b9f456SAndroid Build Coastguard Worker  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
165*58b9f456SAndroid Build Coastguard Worker  operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
166*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period, class Rep2>
167*58b9f456SAndroid Build Coastguard Worker  constexpr
168*58b9f456SAndroid Build Coastguard Worker  duration<typename common_type<Rep1, Rep2>::type, Period>
169*58b9f456SAndroid Build Coastguard Worker  operator*(const duration<Rep1, Period>& d, const Rep2& s);
170*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period, class Rep2>
171*58b9f456SAndroid Build Coastguard Worker  constexpr
172*58b9f456SAndroid Build Coastguard Worker  duration<typename common_type<Rep1, Rep2>::type, Period>
173*58b9f456SAndroid Build Coastguard Worker  operator*(const Rep1& s, const duration<Rep2, Period>& d);
174*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period, class Rep2>
175*58b9f456SAndroid Build Coastguard Worker  constexpr
176*58b9f456SAndroid Build Coastguard Worker  duration<typename common_type<Rep1, Rep2>::type, Period>
177*58b9f456SAndroid Build Coastguard Worker  operator/(const duration<Rep1, Period>& d, const Rep2& s);
178*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
179*58b9f456SAndroid Build Coastguard Worker  constexpr
180*58b9f456SAndroid Build Coastguard Worker  typename common_type<Rep1, Rep2>::type
181*58b9f456SAndroid Build Coastguard Worker  operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
182*58b9f456SAndroid Build Coastguard Worker
183*58b9f456SAndroid Build Coastguard Worker// duration comparisons
184*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
185*58b9f456SAndroid Build Coastguard Worker   constexpr
186*58b9f456SAndroid Build Coastguard Worker   bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
187*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
188*58b9f456SAndroid Build Coastguard Worker   constexpr
189*58b9f456SAndroid Build Coastguard Worker   bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
190*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
191*58b9f456SAndroid Build Coastguard Worker   constexpr
192*58b9f456SAndroid Build Coastguard Worker   bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
193*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
194*58b9f456SAndroid Build Coastguard Worker   constexpr
195*58b9f456SAndroid Build Coastguard Worker   bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
196*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
197*58b9f456SAndroid Build Coastguard Worker   constexpr
198*58b9f456SAndroid Build Coastguard Worker   bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
199*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Rep2, class Period2>
200*58b9f456SAndroid Build Coastguard Worker   constexpr
201*58b9f456SAndroid Build Coastguard Worker   bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
202*58b9f456SAndroid Build Coastguard Worker
203*58b9f456SAndroid Build Coastguard Worker// duration_cast
204*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Rep, class Period>
205*58b9f456SAndroid Build Coastguard Worker  ToDuration duration_cast(const duration<Rep, Period>& d);
206*58b9f456SAndroid Build Coastguard Worker
207*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Rep, class Period>
208*58b9f456SAndroid Build Coastguard Worker    constexpr ToDuration floor(const duration<Rep, Period>& d);    // C++17
209*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Rep, class Period>
210*58b9f456SAndroid Build Coastguard Worker    constexpr ToDuration ceil(const duration<Rep, Period>& d);     // C++17
211*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Rep, class Period>
212*58b9f456SAndroid Build Coastguard Worker    constexpr ToDuration round(const duration<Rep, Period>& d);    // C++17
213*58b9f456SAndroid Build Coastguard Worker
214*58b9f456SAndroid Build Coastguard Worker// duration I/O is elsewhere
215*58b9f456SAndroid Build Coastguard Worker
216*58b9f456SAndroid Build Coastguard Worker// time_point arithmetic (all constexpr in C++14)
217*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Rep2, class Period2>
218*58b9f456SAndroid Build Coastguard Worker  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
219*58b9f456SAndroid Build Coastguard Worker  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
220*58b9f456SAndroid Build Coastguard Workertemplate <class Rep1, class Period1, class Clock, class Duration2>
221*58b9f456SAndroid Build Coastguard Worker  time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
222*58b9f456SAndroid Build Coastguard Worker  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
223*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Rep2, class Period2>
224*58b9f456SAndroid Build Coastguard Worker  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
225*58b9f456SAndroid Build Coastguard Worker  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
226*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
227*58b9f456SAndroid Build Coastguard Worker  typename common_type<Duration1, Duration2>::type
228*58b9f456SAndroid Build Coastguard Worker  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
229*58b9f456SAndroid Build Coastguard Worker
230*58b9f456SAndroid Build Coastguard Worker// time_point comparisons (all constexpr in C++14)
231*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
232*58b9f456SAndroid Build Coastguard Worker   bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
233*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
234*58b9f456SAndroid Build Coastguard Worker   bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
235*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
236*58b9f456SAndroid Build Coastguard Worker   bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
237*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
238*58b9f456SAndroid Build Coastguard Worker   bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
239*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
240*58b9f456SAndroid Build Coastguard Worker   bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
241*58b9f456SAndroid Build Coastguard Workertemplate <class Clock, class Duration1, class Duration2>
242*58b9f456SAndroid Build Coastguard Worker   bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
243*58b9f456SAndroid Build Coastguard Worker
244*58b9f456SAndroid Build Coastguard Worker// time_point_cast (constexpr in C++14)
245*58b9f456SAndroid Build Coastguard Worker
246*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Clock, class Duration>
247*58b9f456SAndroid Build Coastguard Worker  time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
248*58b9f456SAndroid Build Coastguard Worker
249*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Clock, class Duration>
250*58b9f456SAndroid Build Coastguard Worker    constexpr time_point<Clock, ToDuration>
251*58b9f456SAndroid Build Coastguard Worker    floor(const time_point<Clock, Duration>& tp);                  // C++17
252*58b9f456SAndroid Build Coastguard Worker
253*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Clock, class Duration>
254*58b9f456SAndroid Build Coastguard Worker    constexpr time_point<Clock, ToDuration>
255*58b9f456SAndroid Build Coastguard Worker    ceil(const time_point<Clock, Duration>& tp);                   // C++17
256*58b9f456SAndroid Build Coastguard Worker
257*58b9f456SAndroid Build Coastguard Workertemplate <class ToDuration, class Clock, class Duration>
258*58b9f456SAndroid Build Coastguard Worker    constexpr time_point<Clock, ToDuration>
259*58b9f456SAndroid Build Coastguard Worker    round(const time_point<Clock, Duration>& tp);                  // C++17
260*58b9f456SAndroid Build Coastguard Worker
261*58b9f456SAndroid Build Coastguard Workertemplate <class Rep, class Period>
262*58b9f456SAndroid Build Coastguard Worker    constexpr duration<Rep, Period> abs(duration<Rep, Period> d);  // C++17
263*58b9f456SAndroid Build Coastguard Worker
264*58b9f456SAndroid Build Coastguard Worker// Clocks
265*58b9f456SAndroid Build Coastguard Worker
266*58b9f456SAndroid Build Coastguard Workerclass system_clock
267*58b9f456SAndroid Build Coastguard Worker{
268*58b9f456SAndroid Build Coastguard Workerpublic:
269*58b9f456SAndroid Build Coastguard Worker    typedef microseconds                     duration;
270*58b9f456SAndroid Build Coastguard Worker    typedef duration::rep                    rep;
271*58b9f456SAndroid Build Coastguard Worker    typedef duration::period                 period;
272*58b9f456SAndroid Build Coastguard Worker    typedef chrono::time_point<system_clock> time_point;
273*58b9f456SAndroid Build Coastguard Worker    static const bool is_steady =            false; // constexpr in C++14
274*58b9f456SAndroid Build Coastguard Worker
275*58b9f456SAndroid Build Coastguard Worker    static time_point now() noexcept;
276*58b9f456SAndroid Build Coastguard Worker    static time_t     to_time_t  (const time_point& __t) noexcept;
277*58b9f456SAndroid Build Coastguard Worker    static time_point from_time_t(time_t __t) noexcept;
278*58b9f456SAndroid Build Coastguard Worker};
279*58b9f456SAndroid Build Coastguard Worker
280*58b9f456SAndroid Build Coastguard Workertemplate <class Duration>
281*58b9f456SAndroid Build Coastguard Worker  using sys_time  = time_point<system_clock, Duration>; // C++20
282*58b9f456SAndroid Build Coastguard Workerusing sys_seconds = sys_time<seconds>;                  // C++20
283*58b9f456SAndroid Build Coastguard Workerusing sys_days    = sys_time<days>;                     // C++20
284*58b9f456SAndroid Build Coastguard Worker
285*58b9f456SAndroid Build Coastguard Workerclass utc_clock;                                        // C++20
286*58b9f456SAndroid Build Coastguard Worker
287*58b9f456SAndroid Build Coastguard Workertemplate <class Duration>
288*58b9f456SAndroid Build Coastguard Worker  using utc_time  = time_point<utc_clock, Duration>;    // C++20
289*58b9f456SAndroid Build Coastguard Workerusing utc_seconds = utc_time<seconds>;                  // C++20
290*58b9f456SAndroid Build Coastguard Worker
291*58b9f456SAndroid Build Coastguard Workerclass tai_clock;                                        // C++20
292*58b9f456SAndroid Build Coastguard Worker
293*58b9f456SAndroid Build Coastguard Workertemplate <class Duration>
294*58b9f456SAndroid Build Coastguard Worker  using tai_time  = time_point<tai_clock, Duration>;    // C++20
295*58b9f456SAndroid Build Coastguard Workerusing tai_seconds = tai_time<seconds>;                  // C++20
296*58b9f456SAndroid Build Coastguard Worker
297*58b9f456SAndroid Build Coastguard Workerclass file_clock;                                       // C++20
298*58b9f456SAndroid Build Coastguard Worker
299*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
300*58b9f456SAndroid Build Coastguard Worker  using file_time = time_point<file_clock, Duration>;   // C++20
301*58b9f456SAndroid Build Coastguard Worker
302*58b9f456SAndroid Build Coastguard Workerclass steady_clock
303*58b9f456SAndroid Build Coastguard Worker{
304*58b9f456SAndroid Build Coastguard Workerpublic:
305*58b9f456SAndroid Build Coastguard Worker    typedef nanoseconds                                   duration;
306*58b9f456SAndroid Build Coastguard Worker    typedef duration::rep                                 rep;
307*58b9f456SAndroid Build Coastguard Worker    typedef duration::period                              period;
308*58b9f456SAndroid Build Coastguard Worker    typedef chrono::time_point<steady_clock, duration>    time_point;
309*58b9f456SAndroid Build Coastguard Worker    static const bool is_steady =                         true; // constexpr in C++14
310*58b9f456SAndroid Build Coastguard Worker
311*58b9f456SAndroid Build Coastguard Worker    static time_point now() noexcept;
312*58b9f456SAndroid Build Coastguard Worker};
313*58b9f456SAndroid Build Coastguard Worker
314*58b9f456SAndroid Build Coastguard Workertypedef steady_clock high_resolution_clock;
315*58b9f456SAndroid Build Coastguard Worker
316*58b9f456SAndroid Build Coastguard Worker// 25.7.8, local time           // C++20
317*58b9f456SAndroid Build Coastguard Workerstruct local_t {};
318*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
319*58b9f456SAndroid Build Coastguard Worker  using local_time  = time_point<local_t, Duration>;
320*58b9f456SAndroid Build Coastguard Workerusing local_seconds = local_time<seconds>;
321*58b9f456SAndroid Build Coastguard Workerusing local_days    = local_time<days>;
322*58b9f456SAndroid Build Coastguard Worker
323*58b9f456SAndroid Build Coastguard Worker// 25.7.9, time_point conversions template<class DestClock, class SourceClock>    // C++20
324*58b9f456SAndroid Build Coastguard Workerstruct clock_time_conversion;
325*58b9f456SAndroid Build Coastguard Worker
326*58b9f456SAndroid Build Coastguard Workertemplate<class DestClock, class SourceClock, class Duration>
327*58b9f456SAndroid Build Coastguard Worker  auto clock_cast(const time_point<SourceClock, Duration>& t);
328*58b9f456SAndroid Build Coastguard Worker
329*58b9f456SAndroid Build Coastguard Worker// 25.8.2, class last_spec    // C++20
330*58b9f456SAndroid Build Coastguard Workerstruct last_spec;
331*58b9f456SAndroid Build Coastguard Worker
332*58b9f456SAndroid Build Coastguard Worker// 25.8.3, class day          // C++20
333*58b9f456SAndroid Build Coastguard Worker
334*58b9f456SAndroid Build Coastguard Workerclass day;
335*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const day& x, const day& y) noexcept;
336*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const day& x, const day& y) noexcept;
337*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const day& x, const day& y) noexcept;
338*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const day& x, const day& y) noexcept;
339*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const day& x, const day& y) noexcept;
340*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const day& x, const day& y) noexcept;
341*58b9f456SAndroid Build Coastguard Workerconstexpr day  operator+(const day&  x, const days& y) noexcept;
342*58b9f456SAndroid Build Coastguard Workerconstexpr day  operator+(const days& x, const day&  y) noexcept;
343*58b9f456SAndroid Build Coastguard Workerconstexpr day  operator-(const day&  x, const days& y) noexcept;
344*58b9f456SAndroid Build Coastguard Workerconstexpr days operator-(const day&  x, const day&  y) noexcept;
345*58b9f456SAndroid Build Coastguard Worker
346*58b9f456SAndroid Build Coastguard Worker// 25.8.4, class month    // C++20
347*58b9f456SAndroid Build Coastguard Workerclass month;
348*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const month& x, const month& y) noexcept;
349*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const month& x, const month& y) noexcept;
350*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const month& x, const month& y) noexcept;
351*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const month& x, const month& y) noexcept;
352*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const month& x, const month& y) noexcept;
353*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const month& x, const month& y) noexcept;
354*58b9f456SAndroid Build Coastguard Workerconstexpr month  operator+(const month&  x, const months& y) noexcept;
355*58b9f456SAndroid Build Coastguard Workerconstexpr month  operator+(const months& x,  const month& y) noexcept;
356*58b9f456SAndroid Build Coastguard Workerconstexpr month  operator-(const month&  x, const months& y) noexcept;
357*58b9f456SAndroid Build Coastguard Workerconstexpr months operator-(const month&  x,  const month& y) noexcept;
358*58b9f456SAndroid Build Coastguard Worker
359*58b9f456SAndroid Build Coastguard Worker// 25.8.5, class year    // C++20
360*58b9f456SAndroid Build Coastguard Workerclass year;
361*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const year& x, const year& y) noexcept;
362*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const year& x, const year& y) noexcept;
363*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const year& x, const year& y) noexcept;
364*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const year& x, const year& y) noexcept;
365*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const year& x, const year& y) noexcept;
366*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const year& x, const year& y) noexcept;
367*58b9f456SAndroid Build Coastguard Workerconstexpr year  operator+(const year&  x, const years& y) noexcept;
368*58b9f456SAndroid Build Coastguard Workerconstexpr year  operator+(const years& x, const year&  y) noexcept;
369*58b9f456SAndroid Build Coastguard Workerconstexpr year  operator-(const year&  x, const years& y) noexcept;
370*58b9f456SAndroid Build Coastguard Workerconstexpr years operator-(const year&  x, const year&  y) noexcept;
371*58b9f456SAndroid Build Coastguard Worker
372*58b9f456SAndroid Build Coastguard Worker// 25.8.6, class weekday    // C++20
373*58b9f456SAndroid Build Coastguard Workerclass weekday;
374*58b9f456SAndroid Build Coastguard Worker
375*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const weekday& x, const weekday& y) noexcept;
376*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
377*58b9f456SAndroid Build Coastguard Workerconstexpr weekday operator+(const weekday& x, const days&    y) noexcept;
378*58b9f456SAndroid Build Coastguard Workerconstexpr weekday operator+(const days&    x, const weekday& y) noexcept;
379*58b9f456SAndroid Build Coastguard Workerconstexpr weekday operator-(const weekday& x, const days&    y) noexcept;
380*58b9f456SAndroid Build Coastguard Workerconstexpr days    operator-(const weekday& x, const weekday& y) noexcept;
381*58b9f456SAndroid Build Coastguard Worker
382*58b9f456SAndroid Build Coastguard Worker// 25.8.7, class weekday_indexed    // C++20
383*58b9f456SAndroid Build Coastguard Worker
384*58b9f456SAndroid Build Coastguard Workerclass weekday_indexed;
385*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
386*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
387*58b9f456SAndroid Build Coastguard Worker
388*58b9f456SAndroid Build Coastguard Worker// 25.8.8, class weekday_last    // C++20
389*58b9f456SAndroid Build Coastguard Workerclass weekday_last;
390*58b9f456SAndroid Build Coastguard Worker
391*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
392*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
393*58b9f456SAndroid Build Coastguard Worker
394*58b9f456SAndroid Build Coastguard Worker// 25.8.9, class month_day    // C++20
395*58b9f456SAndroid Build Coastguard Workerclass month_day;
396*58b9f456SAndroid Build Coastguard Worker
397*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const month_day& x, const month_day& y) noexcept;
398*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
399*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const month_day& x, const month_day& y) noexcept;
400*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const month_day& x, const month_day& y) noexcept;
401*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
402*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
403*58b9f456SAndroid Build Coastguard Worker
404*58b9f456SAndroid Build Coastguard Worker
405*58b9f456SAndroid Build Coastguard Worker// 25.8.10, class month_day_last    // C++20
406*58b9f456SAndroid Build Coastguard Workerclass month_day_last;
407*58b9f456SAndroid Build Coastguard Worker
408*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
409*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
410*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
411*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
412*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
413*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
414*58b9f456SAndroid Build Coastguard Worker
415*58b9f456SAndroid Build Coastguard Worker// 25.8.11, class month_weekday    // C++20
416*58b9f456SAndroid Build Coastguard Workerclass month_weekday;
417*58b9f456SAndroid Build Coastguard Worker
418*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
419*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;
420*58b9f456SAndroid Build Coastguard Worker
421*58b9f456SAndroid Build Coastguard Worker// 25.8.12, class month_weekday_last    // C++20
422*58b9f456SAndroid Build Coastguard Workerclass month_weekday_last;
423*58b9f456SAndroid Build Coastguard Worker
424*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
425*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;
426*58b9f456SAndroid Build Coastguard Worker
427*58b9f456SAndroid Build Coastguard Worker
428*58b9f456SAndroid Build Coastguard Worker// 25.8.13, class year_month    // C++20
429*58b9f456SAndroid Build Coastguard Workerclass year_month;
430*58b9f456SAndroid Build Coastguard Worker
431*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const year_month& x, const year_month& y) noexcept;
432*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
433*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const year_month& x, const year_month& y) noexcept;
434*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const year_month& x, const year_month& y) noexcept;
435*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
436*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
437*58b9f456SAndroid Build Coastguard Worker
438*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
439*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
440*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
441*58b9f456SAndroid Build Coastguard Workerconstexpr months operator-(const year_month& x, const year_month& y) noexcept;
442*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
443*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
444*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
445*58b9f456SAndroid Build Coastguard Worker
446*58b9f456SAndroid Build Coastguard Worker// 25.8.14, class year_month_day class    // C++20
447*58b9f456SAndroid Build Coastguard Workeryear_month_day;
448*58b9f456SAndroid Build Coastguard Worker
449*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
450*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
451*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
452*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
453*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
454*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
455*58b9f456SAndroid Build Coastguard Worker
456*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
457*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
458*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
459*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
460*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
461*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
462*58b9f456SAndroid Build Coastguard Worker
463*58b9f456SAndroid Build Coastguard Worker
464*58b9f456SAndroid Build Coastguard Worker// 25.8.15, class year_month_day_last    // C++20
465*58b9f456SAndroid Build Coastguard Workerclass year_month_day_last;
466*58b9f456SAndroid Build Coastguard Worker
467*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const year_month_day_last& x,
468*58b9f456SAndroid Build Coastguard Worker                          const year_month_day_last& y) noexcept;
469*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const year_month_day_last& x,
470*58b9f456SAndroid Build Coastguard Worker                          const year_month_day_last& y) noexcept;
471*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (const year_month_day_last& x,
472*58b9f456SAndroid Build Coastguard Worker                          const year_month_day_last& y) noexcept;
473*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (const year_month_day_last& x,
474*58b9f456SAndroid Build Coastguard Worker                          const year_month_day_last& y) noexcept;
475*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(const year_month_day_last& x,
476*58b9f456SAndroid Build Coastguard Worker                          const year_month_day_last& y) noexcept;
477*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(const year_month_day_last& x,
478*58b9f456SAndroid Build Coastguard Worker                          const year_month_day_last& y) noexcept;
479*58b9f456SAndroid Build Coastguard Worker
480*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
481*58b9f456SAndroid Build Coastguard Worker  operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
482*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
483*58b9f456SAndroid Build Coastguard Worker  operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
484*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
485*58b9f456SAndroid Build Coastguard Worker  operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
486*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
487*58b9f456SAndroid Build Coastguard Worker  operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
488*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
489*58b9f456SAndroid Build Coastguard Worker  operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
490*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
491*58b9f456SAndroid Build Coastguard Worker  operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
492*58b9f456SAndroid Build Coastguard Worker
493*58b9f456SAndroid Build Coastguard Worker// 25.8.16, class year_month_weekday    // C++20
494*58b9f456SAndroid Build Coastguard Workerclass year_month_weekday;
495*58b9f456SAndroid Build Coastguard Worker
496*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const year_month_weekday& x,
497*58b9f456SAndroid Build Coastguard Worker                          const year_month_weekday& y) noexcept;
498*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const year_month_weekday& x,
499*58b9f456SAndroid Build Coastguard Worker                          const year_month_weekday& y) noexcept;
500*58b9f456SAndroid Build Coastguard Worker
501*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
502*58b9f456SAndroid Build Coastguard Worker  operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
503*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
504*58b9f456SAndroid Build Coastguard Worker  operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
505*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
506*58b9f456SAndroid Build Coastguard Worker  operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
507*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
508*58b9f456SAndroid Build Coastguard Worker  operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
509*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
510*58b9f456SAndroid Build Coastguard Worker  operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
511*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
512*58b9f456SAndroid Build Coastguard Worker  operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
513*58b9f456SAndroid Build Coastguard Worker
514*58b9f456SAndroid Build Coastguard Worker// 25.8.17, class year_month_weekday_last    // C++20
515*58b9f456SAndroid Build Coastguard Workerclass year_month_weekday_last;
516*58b9f456SAndroid Build Coastguard Worker
517*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(const year_month_weekday_last& x,
518*58b9f456SAndroid Build Coastguard Worker                          const year_month_weekday_last& y) noexcept;
519*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(const year_month_weekday_last& x,
520*58b9f456SAndroid Build Coastguard Worker                          const year_month_weekday_last& y) noexcept;
521*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
522*58b9f456SAndroid Build Coastguard Worker  operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
523*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
524*58b9f456SAndroid Build Coastguard Worker  operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
525*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
526*58b9f456SAndroid Build Coastguard Worker  operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
527*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
528*58b9f456SAndroid Build Coastguard Worker  operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
529*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
530*58b9f456SAndroid Build Coastguard Worker  operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
531*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
532*58b9f456SAndroid Build Coastguard Worker  operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
533*58b9f456SAndroid Build Coastguard Worker
534*58b9f456SAndroid Build Coastguard Worker// 25.8.18, civil calendar conventional syntax operators    // C++20
535*58b9f456SAndroid Build Coastguard Workerconstexpr year_month
536*58b9f456SAndroid Build Coastguard Worker  operator/(const year& y, const month& m) noexcept;
537*58b9f456SAndroid Build Coastguard Workerconstexpr year_month
538*58b9f456SAndroid Build Coastguard Worker  operator/(const year& y, int m) noexcept;
539*58b9f456SAndroid Build Coastguard Workerconstexpr month_day
540*58b9f456SAndroid Build Coastguard Worker  operator/(const month& m, const day& d) noexcept;
541*58b9f456SAndroid Build Coastguard Workerconstexpr month_day
542*58b9f456SAndroid Build Coastguard Worker  operator/(const month& m, int d) noexcept;
543*58b9f456SAndroid Build Coastguard Workerconstexpr month_day
544*58b9f456SAndroid Build Coastguard Worker  operator/(int m, const day& d) noexcept;
545*58b9f456SAndroid Build Coastguard Workerconstexpr month_day
546*58b9f456SAndroid Build Coastguard Worker  operator/(const day& d, const month& m) noexcept;
547*58b9f456SAndroid Build Coastguard Workerconstexpr month_day
548*58b9f456SAndroid Build Coastguard Worker  operator/(const day& d, int m) noexcept;
549*58b9f456SAndroid Build Coastguard Workerconstexpr month_day_last
550*58b9f456SAndroid Build Coastguard Worker  operator/(const month& m, last_spec) noexcept;
551*58b9f456SAndroid Build Coastguard Workerconstexpr month_day_last
552*58b9f456SAndroid Build Coastguard Worker  operator/(int m, last_spec) noexcept;
553*58b9f456SAndroid Build Coastguard Workerconstexpr month_day_last
554*58b9f456SAndroid Build Coastguard Worker  operator/(last_spec, const month& m) noexcept;
555*58b9f456SAndroid Build Coastguard Workerconstexpr month_day_last
556*58b9f456SAndroid Build Coastguard Worker  operator/(last_spec, int m) noexcept;
557*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday
558*58b9f456SAndroid Build Coastguard Worker  operator/(const month& m, const weekday_indexed& wdi) noexcept;
559*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday
560*58b9f456SAndroid Build Coastguard Worker  operator/(int m, const weekday_indexed& wdi) noexcept;
561*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday
562*58b9f456SAndroid Build Coastguard Worker  operator/(const weekday_indexed& wdi, const month& m) noexcept;
563*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday
564*58b9f456SAndroid Build Coastguard Worker  operator/(const weekday_indexed& wdi, int m) noexcept;
565*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday_last
566*58b9f456SAndroid Build Coastguard Worker  operator/(const month& m, const weekday_last& wdl) noexcept;
567*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday_last
568*58b9f456SAndroid Build Coastguard Worker  operator/(int m, const weekday_last& wdl) noexcept;
569*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday_last
570*58b9f456SAndroid Build Coastguard Worker  operator/(const weekday_last& wdl, const month& m) noexcept;
571*58b9f456SAndroid Build Coastguard Workerconstexpr month_weekday_last
572*58b9f456SAndroid Build Coastguard Worker  operator/(const weekday_last& wdl, int m) noexcept;
573*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day
574*58b9f456SAndroid Build Coastguard Worker  operator/(const year_month& ym, const day& d) noexcept;
575*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day
576*58b9f456SAndroid Build Coastguard Worker  operator/(const year_month& ym, int d) noexcept;
577*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day
578*58b9f456SAndroid Build Coastguard Worker  operator/(const year& y, const month_day& md) noexcept;
579*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day
580*58b9f456SAndroid Build Coastguard Worker  operator/(int y, const month_day& md) noexcept;
581*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day
582*58b9f456SAndroid Build Coastguard Worker  operator/(const month_day& md, const year& y) noexcept;
583*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day
584*58b9f456SAndroid Build Coastguard Worker  operator/(const month_day& md, int y) noexcept;
585*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
586*58b9f456SAndroid Build Coastguard Worker  operator/(const year_month& ym, last_spec) noexcept;
587*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
588*58b9f456SAndroid Build Coastguard Worker  operator/(const year& y, const month_day_last& mdl) noexcept;
589*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
590*58b9f456SAndroid Build Coastguard Worker  operator/(int y, const month_day_last& mdl) noexcept;
591*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
592*58b9f456SAndroid Build Coastguard Worker  operator/(const month_day_last& mdl, const year& y) noexcept;
593*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_day_last
594*58b9f456SAndroid Build Coastguard Worker  operator/(const month_day_last& mdl, int y) noexcept;
595*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
596*58b9f456SAndroid Build Coastguard Worker  operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
597*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
598*58b9f456SAndroid Build Coastguard Worker  operator/(const year& y, const month_weekday& mwd) noexcept;
599*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
600*58b9f456SAndroid Build Coastguard Worker  operator/(int y, const month_weekday& mwd) noexcept;
601*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
602*58b9f456SAndroid Build Coastguard Worker  operator/(const month_weekday& mwd, const year& y) noexcept;
603*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday
604*58b9f456SAndroid Build Coastguard Worker  operator/(const month_weekday& mwd, int y) noexcept;
605*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
606*58b9f456SAndroid Build Coastguard Worker  operator/(const year_month& ym, const weekday_last& wdl) noexcept;
607*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
608*58b9f456SAndroid Build Coastguard Worker  operator/(const year& y, const month_weekday_last& mwdl) noexcept;
609*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
610*58b9f456SAndroid Build Coastguard Worker  operator/(int y, const month_weekday_last& mwdl) noexcept;
611*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
612*58b9f456SAndroid Build Coastguard Worker  operator/(const month_weekday_last& mwdl, const year& y) noexcept;
613*58b9f456SAndroid Build Coastguard Workerconstexpr year_month_weekday_last
614*58b9f456SAndroid Build Coastguard Worker  operator/(const month_weekday_last& mwdl, int y) noexcept;
615*58b9f456SAndroid Build Coastguard Worker
616*58b9f456SAndroid Build Coastguard Worker// 25.9, class template time_of_day    // C++20
617*58b9f456SAndroid Build Coastguard Workertemplate<class Duration> class time_of_day;
618*58b9f456SAndroid Build Coastguard Worker
619*58b9f456SAndroid Build Coastguard Workertemplate<> class time_of_day<hours>;
620*58b9f456SAndroid Build Coastguard Workertemplate<> class time_of_day<minutes>;
621*58b9f456SAndroid Build Coastguard Workertemplate<> class time_of_day<seconds>;
622*58b9f456SAndroid Build Coastguard Workertemplate<class Rep, class Period> class time_of_day<duration<Rep, Period>>;
623*58b9f456SAndroid Build Coastguard Worker
624*58b9f456SAndroid Build Coastguard Worker// 25.10.2, time zone database     // C++20
625*58b9f456SAndroid Build Coastguard Workerstruct tzdb;
626*58b9f456SAndroid Build Coastguard Workerclass tzdb_list;
627*58b9f456SAndroid Build Coastguard Worker
628*58b9f456SAndroid Build Coastguard Worker// 25.10.2.3, time zone database access    // C++20
629*58b9f456SAndroid Build Coastguard Workerconst tzdb& get_tzdb();
630*58b9f456SAndroid Build Coastguard Workertzdb_list& get_tzdb_list();
631*58b9f456SAndroid Build Coastguard Workerconst time_zone* locate_zone(string_view tz_name);
632*58b9f456SAndroid Build Coastguard Workerconst time_zone* current_zone();
633*58b9f456SAndroid Build Coastguard Worker
634*58b9f456SAndroid Build Coastguard Worker// 25.10.2.4, remote time zone database support    // C++20
635*58b9f456SAndroid Build Coastguard Workerconst tzdb& reload_tzdb();
636*58b9f456SAndroid Build Coastguard Workerstring remote_version();
637*58b9f456SAndroid Build Coastguard Worker
638*58b9f456SAndroid Build Coastguard Worker// 25.10.3, exception classes    // C++20
639*58b9f456SAndroid Build Coastguard Workerclass nonexistent_local_time;
640*58b9f456SAndroid Build Coastguard Workerclass ambiguous_local_time;
641*58b9f456SAndroid Build Coastguard Worker
642*58b9f456SAndroid Build Coastguard Worker// 25.10.4, information classes    // C++20
643*58b9f456SAndroid Build Coastguard Workerstruct sys_info;
644*58b9f456SAndroid Build Coastguard Workerstruct local_info;
645*58b9f456SAndroid Build Coastguard Worker
646*58b9f456SAndroid Build Coastguard Worker// 25.10.5, class time_zone    // C++20
647*58b9f456SAndroid Build Coastguard Workerenum class choose {earliest, latest};
648*58b9f456SAndroid Build Coastguard Workerclass time_zone;
649*58b9f456SAndroid Build Coastguard Workerbool operator==(const time_zone& x, const time_zone& y) noexcept;
650*58b9f456SAndroid Build Coastguard Workerbool operator!=(const time_zone& x, const time_zone& y) noexcept;
651*58b9f456SAndroid Build Coastguard Workerbool operator<(const time_zone& x, const time_zone& y) noexcept;
652*58b9f456SAndroid Build Coastguard Workerbool operator>(const time_zone& x, const time_zone& y) noexcept;
653*58b9f456SAndroid Build Coastguard Workerbool operator<=(const time_zone& x, const time_zone& y) noexcept;
654*58b9f456SAndroid Build Coastguard Workerbool operator>=(const time_zone& x, const time_zone& y) noexcept;
655*58b9f456SAndroid Build Coastguard Worker
656*58b9f456SAndroid Build Coastguard Worker// 25.10.6, class template zoned_traits    // C++20
657*58b9f456SAndroid Build Coastguard Workertemplate<class T> struct zoned_traits;
658*58b9f456SAndroid Build Coastguard Worker
659*58b9f456SAndroid Build Coastguard Worker// 25.10.7, class template zoned_time    // C++20
660*58b9f456SAndroid Build Coastguard Workertemplate<class Duration, class TimeZonePtr = const time_zone*> class zoned_time;
661*58b9f456SAndroid Build Coastguard Workerusing zoned_seconds = zoned_time<seconds>;
662*58b9f456SAndroid Build Coastguard Worker
663*58b9f456SAndroid Build Coastguard Workertemplate<class Duration1, class Duration2, class TimeZonePtr>
664*58b9f456SAndroid Build Coastguard Worker  bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
665*58b9f456SAndroid Build Coastguard Worker                  const zoned_time<Duration2, TimeZonePtr>& y);
666*58b9f456SAndroid Build Coastguard Workertemplate<class Duration1, class Duration2, class TimeZonePtr>
667*58b9f456SAndroid Build Coastguard Worker  bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x,
668*58b9f456SAndroid Build Coastguard Worker                  const zoned_time<Duration2, TimeZonePtr>& y);
669*58b9f456SAndroid Build Coastguard Worker
670*58b9f456SAndroid Build Coastguard Worker// 25.10.8, leap second support    // C++20
671*58b9f456SAndroid Build Coastguard Workerclass leap;
672*58b9f456SAndroid Build Coastguard Worker
673*58b9f456SAndroid Build Coastguard Workerbool operator==(const leap& x, const leap& y);
674*58b9f456SAndroid Build Coastguard Workerbool operator!=(const leap& x, const leap& y);
675*58b9f456SAndroid Build Coastguard Workerbool operator< (const leap& x, const leap& y);
676*58b9f456SAndroid Build Coastguard Workerbool operator> (const leap& x, const leap& y);
677*58b9f456SAndroid Build Coastguard Workerbool operator<=(const leap& x, const leap& y);
678*58b9f456SAndroid Build Coastguard Workerbool operator>=(const leap& x, const leap& y);
679*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
680*58b9f456SAndroid Build Coastguard Worker  bool operator==(const leap& x, const sys_time<Duration>& y);
681*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
682*58b9f456SAndroid Build Coastguard Worker  bool operator==(const sys_time<Duration>& x, const leap& y);
683*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
684*58b9f456SAndroid Build Coastguard Worker  bool operator!=(const leap& x, const sys_time<Duration>& y);
685*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
686*58b9f456SAndroid Build Coastguard Worker  bool operator!=(const sys_time<Duration>& x, const leap& y);
687*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
688*58b9f456SAndroid Build Coastguard Worker  bool operator< (const leap& x, const sys_time<Duration>& y);
689*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
690*58b9f456SAndroid Build Coastguard Worker  bool operator< (const sys_time<Duration>& x, const leap& y);
691*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
692*58b9f456SAndroid Build Coastguard Worker  bool operator> (const leap& x, const sys_time<Duration>& y);
693*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
694*58b9f456SAndroid Build Coastguard Worker  bool operator> (const sys_time<Duration>& x, const leap& y);
695*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
696*58b9f456SAndroid Build Coastguard Worker  bool operator<=(const leap& x, const sys_time<Duration>& y);
697*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
698*58b9f456SAndroid Build Coastguard Worker  bool operator<=(const sys_time<Duration>& x, const leap& y);
699*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
700*58b9f456SAndroid Build Coastguard Worker  bool operator>=(const leap& x, const sys_time<Duration>& y);
701*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
702*58b9f456SAndroid Build Coastguard Worker  bool operator>=(const sys_time<Duration>& x, const leap& y);
703*58b9f456SAndroid Build Coastguard Worker
704*58b9f456SAndroid Build Coastguard Worker// 25.10.9, class link    // C++20
705*58b9f456SAndroid Build Coastguard Workerclass link;
706*58b9f456SAndroid Build Coastguard Workerbool operator==(const link& x, const link& y);
707*58b9f456SAndroid Build Coastguard Workerbool operator!=(const link& x, const link& y);
708*58b9f456SAndroid Build Coastguard Workerbool operator< (const link& x, const link& y);
709*58b9f456SAndroid Build Coastguard Workerbool operator> (const link& x, const link& y);
710*58b9f456SAndroid Build Coastguard Workerbool operator<=(const link& x, const link& y);
711*58b9f456SAndroid Build Coastguard Workerbool operator>=(const link& x, const link& y);
712*58b9f456SAndroid Build Coastguard Worker
713*58b9f456SAndroid Build Coastguard Worker// 25.11, formatting    // C++20
714*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class Streamable>
715*58b9f456SAndroid Build Coastguard Worker  basic_string<charT>
716*58b9f456SAndroid Build Coastguard Worker    format(const charT* fmt, const Streamable& s);
717*58b9f456SAndroid Build Coastguard Worker
718*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class Streamable>
719*58b9f456SAndroid Build Coastguard Worker  basic_string<charT>
720*58b9f456SAndroid Build Coastguard Worker    format(const locale& loc, const charT* fmt, const Streamable& s);
721*58b9f456SAndroid Build Coastguard Worker
722*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Alloc, class Streamable>
723*58b9f456SAndroid Build Coastguard Worker  basic_string<charT, traits, Alloc>
724*58b9f456SAndroid Build Coastguard Worker    format(const basic_string<charT, traits, Alloc>& fmt, const Streamable& s);
725*58b9f456SAndroid Build Coastguard Worker
726*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Alloc, class Streamable>
727*58b9f456SAndroid Build Coastguard Worker  basic_string<charT, traits, Alloc>
728*58b9f456SAndroid Build Coastguard Worker    format(const locale& loc, const basic_string<charT, traits, Alloc>& fmt,
729*58b9f456SAndroid Build Coastguard Worker           const Streamable& s);
730*58b9f456SAndroid Build Coastguard Worker
731*58b9f456SAndroid Build Coastguard Worker// 25.12, parsing    // C++20
732*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Alloc, class Parsable>
733*58b9f456SAndroid Build Coastguard Workerunspecified
734*58b9f456SAndroid Build Coastguard Worker    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp);
735*58b9f456SAndroid Build Coastguard Worker
736*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Alloc, class Parsable>
737*58b9f456SAndroid Build Coastguard Workerunspecified
738*58b9f456SAndroid Build Coastguard Worker    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
739*58b9f456SAndroid Build Coastguard Worker          basic_string<charT, traits, Alloc>& abbrev);
740*58b9f456SAndroid Build Coastguard Worker
741*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Alloc, class Parsable>
742*58b9f456SAndroid Build Coastguard Workerunspecified
743*58b9f456SAndroid Build Coastguard Worker    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
744*58b9f456SAndroid Build Coastguard Worker          minutes& offset);
745*58b9f456SAndroid Build Coastguard Worker
746*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Alloc, class Parsable>
747*58b9f456SAndroid Build Coastguard Workerunspecified
748*58b9f456SAndroid Build Coastguard Worker    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
749*58b9f456SAndroid Build Coastguard Worker          basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
750*58b9f456SAndroid Build Coastguard Worker
751*58b9f456SAndroid Build Coastguard Worker// calendrical constants
752*58b9f456SAndroid Build Coastguard Workerinline constexpr last_spec                              last{};       // C++20
753*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::weekday                        Sunday{0};    // C++20
754*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::weekday                        Monday{1};    // C++20
755*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::weekday                        Tuesday{2};   // C++20
756*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::weekday                        Wednesday{3}; // C++20
757*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::weekday                        Thursday{4};  // C++20
758*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::weekday                        Friday{5};    // C++20
759*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::weekday                        Saturday{6};  // C++20
760*58b9f456SAndroid Build Coastguard Worker
761*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          January{1};   // C++20
762*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          February{2};  // C++20
763*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          March{3};     // C++20
764*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          April{4};     // C++20
765*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          May{5};       // C++20
766*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          June{6};      // C++20
767*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          July{7};      // C++20
768*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          August{8};    // C++20
769*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          September{9}; // C++20
770*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          October{10};  // C++20
771*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          November{11}; // C++20
772*58b9f456SAndroid Build Coastguard Workerinline constexpr chrono::month                          December{12}; // C++20
773*58b9f456SAndroid Build Coastguard Worker}  // chrono
774*58b9f456SAndroid Build Coastguard Worker
775*58b9f456SAndroid Build Coastguard Workerinline namespace literals {
776*58b9f456SAndroid Build Coastguard Worker  inline namespace chrono_literals {
777*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::hours                                 operator ""h(unsigned long long); // C++14
778*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
779*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::minutes                               operator ""min(unsigned long long); // C++14
780*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::duration<unspecified , ratio<60,1>>   operator ""min(long double); // C++14
781*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::seconds                               operator ""s(unsigned long long); // C++14
782*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::duration<unspecified >                operator ""s(long double); // C++14
783*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::milliseconds                          operator ""ms(unsigned long long); // C++14
784*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::duration<unspecified , milli>         operator ""ms(long double); // C++14
785*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::microseconds                          operator ""us(unsigned long long); // C++14
786*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::duration<unspecified , micro>         operator ""us(long double); // C++14
787*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::nanoseconds                           operator ""ns(unsigned long long); // C++14
788*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::duration<unspecified , nano>          operator ""ns(long double); // C++14
789*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::day                                   operator ""d(unsigned long long d) noexcept; // C++20
790*58b9f456SAndroid Build Coastguard Workerconstexpr chrono::year                                  operator ""y(unsigned long long y) noexcept; // C++20
791*58b9f456SAndroid Build Coastguard Worker}  // chrono_literals
792*58b9f456SAndroid Build Coastguard Worker}  // literals
793*58b9f456SAndroid Build Coastguard Worker
794*58b9f456SAndroid Build Coastguard Worker}  // std
795*58b9f456SAndroid Build Coastguard Worker*/
796*58b9f456SAndroid Build Coastguard Worker
797*58b9f456SAndroid Build Coastguard Worker#include <__config>
798*58b9f456SAndroid Build Coastguard Worker#include <ctime>
799*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
800*58b9f456SAndroid Build Coastguard Worker#include <ratio>
801*58b9f456SAndroid Build Coastguard Worker#include <limits>
802*58b9f456SAndroid Build Coastguard Worker#include <version>
803*58b9f456SAndroid Build Coastguard Worker
804*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
805*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
806*58b9f456SAndroid Build Coastguard Worker#endif
807*58b9f456SAndroid Build Coastguard Worker
808*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS
809*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros>
810*58b9f456SAndroid Build Coastguard Worker
811*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
812*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
813*58b9f456SAndroid Build Coastguard Workerstruct _FilesystemClock;
814*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_FILESYSTEM
815*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG
816*58b9f456SAndroid Build Coastguard Worker
817*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
818*58b9f456SAndroid Build Coastguard Worker
819*58b9f456SAndroid Build Coastguard Workernamespace chrono
820*58b9f456SAndroid Build Coastguard Worker{
821*58b9f456SAndroid Build Coastguard Worker
822*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration;
823*58b9f456SAndroid Build Coastguard Worker
824*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
825*58b9f456SAndroid Build Coastguard Workerstruct __is_duration : false_type {};
826*58b9f456SAndroid Build Coastguard Worker
827*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep, class _Period>
828*58b9f456SAndroid Build Coastguard Workerstruct __is_duration<duration<_Rep, _Period> > : true_type  {};
829*58b9f456SAndroid Build Coastguard Worker
830*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep, class _Period>
831*58b9f456SAndroid Build Coastguard Workerstruct __is_duration<const duration<_Rep, _Period> > : true_type  {};
832*58b9f456SAndroid Build Coastguard Worker
833*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep, class _Period>
834*58b9f456SAndroid Build Coastguard Workerstruct __is_duration<volatile duration<_Rep, _Period> > : true_type  {};
835*58b9f456SAndroid Build Coastguard Worker
836*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep, class _Period>
837*58b9f456SAndroid Build Coastguard Workerstruct __is_duration<const volatile duration<_Rep, _Period> > : true_type  {};
838*58b9f456SAndroid Build Coastguard Worker
839*58b9f456SAndroid Build Coastguard Worker} // chrono
840*58b9f456SAndroid Build Coastguard Worker
841*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
842*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>,
843*58b9f456SAndroid Build Coastguard Worker                                         chrono::duration<_Rep2, _Period2> >
844*58b9f456SAndroid Build Coastguard Worker{
845*58b9f456SAndroid Build Coastguard Worker    typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
846*58b9f456SAndroid Build Coastguard Worker                             typename __ratio_gcd<_Period1, _Period2>::type> type;
847*58b9f456SAndroid Build Coastguard Worker};
848*58b9f456SAndroid Build Coastguard Worker
849*58b9f456SAndroid Build Coastguard Workernamespace chrono {
850*58b9f456SAndroid Build Coastguard Worker
851*58b9f456SAndroid Build Coastguard Worker// duration_cast
852*58b9f456SAndroid Build Coastguard Worker
853*58b9f456SAndroid Build Coastguard Workertemplate <class _FromDuration, class _ToDuration,
854*58b9f456SAndroid Build Coastguard Worker          class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
855*58b9f456SAndroid Build Coastguard Worker          bool = _Period::num == 1,
856*58b9f456SAndroid Build Coastguard Worker          bool = _Period::den == 1>
857*58b9f456SAndroid Build Coastguard Workerstruct __duration_cast;
858*58b9f456SAndroid Build Coastguard Worker
859*58b9f456SAndroid Build Coastguard Workertemplate <class _FromDuration, class _ToDuration, class _Period>
860*58b9f456SAndroid Build Coastguard Workerstruct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
861*58b9f456SAndroid Build Coastguard Worker{
862*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
863*58b9f456SAndroid Build Coastguard Worker    _ToDuration operator()(const _FromDuration& __fd) const
864*58b9f456SAndroid Build Coastguard Worker    {
865*58b9f456SAndroid Build Coastguard Worker        return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
866*58b9f456SAndroid Build Coastguard Worker    }
867*58b9f456SAndroid Build Coastguard Worker};
868*58b9f456SAndroid Build Coastguard Worker
869*58b9f456SAndroid Build Coastguard Workertemplate <class _FromDuration, class _ToDuration, class _Period>
870*58b9f456SAndroid Build Coastguard Workerstruct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
871*58b9f456SAndroid Build Coastguard Worker{
872*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
873*58b9f456SAndroid Build Coastguard Worker    _ToDuration operator()(const _FromDuration& __fd) const
874*58b9f456SAndroid Build Coastguard Worker    {
875*58b9f456SAndroid Build Coastguard Worker        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
876*58b9f456SAndroid Build Coastguard Worker        return _ToDuration(static_cast<typename _ToDuration::rep>(
877*58b9f456SAndroid Build Coastguard Worker                           static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
878*58b9f456SAndroid Build Coastguard Worker    }
879*58b9f456SAndroid Build Coastguard Worker};
880*58b9f456SAndroid Build Coastguard Worker
881*58b9f456SAndroid Build Coastguard Workertemplate <class _FromDuration, class _ToDuration, class _Period>
882*58b9f456SAndroid Build Coastguard Workerstruct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
883*58b9f456SAndroid Build Coastguard Worker{
884*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
885*58b9f456SAndroid Build Coastguard Worker    _ToDuration operator()(const _FromDuration& __fd) const
886*58b9f456SAndroid Build Coastguard Worker    {
887*58b9f456SAndroid Build Coastguard Worker        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
888*58b9f456SAndroid Build Coastguard Worker        return _ToDuration(static_cast<typename _ToDuration::rep>(
889*58b9f456SAndroid Build Coastguard Worker                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
890*58b9f456SAndroid Build Coastguard Worker    }
891*58b9f456SAndroid Build Coastguard Worker};
892*58b9f456SAndroid Build Coastguard Worker
893*58b9f456SAndroid Build Coastguard Workertemplate <class _FromDuration, class _ToDuration, class _Period>
894*58b9f456SAndroid Build Coastguard Workerstruct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
895*58b9f456SAndroid Build Coastguard Worker{
896*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
897*58b9f456SAndroid Build Coastguard Worker    _ToDuration operator()(const _FromDuration& __fd) const
898*58b9f456SAndroid Build Coastguard Worker    {
899*58b9f456SAndroid Build Coastguard Worker        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
900*58b9f456SAndroid Build Coastguard Worker        return _ToDuration(static_cast<typename _ToDuration::rep>(
901*58b9f456SAndroid Build Coastguard Worker                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)
902*58b9f456SAndroid Build Coastguard Worker                                                          / static_cast<_Ct>(_Period::den)));
903*58b9f456SAndroid Build Coastguard Worker    }
904*58b9f456SAndroid Build Coastguard Worker};
905*58b9f456SAndroid Build Coastguard Worker
906*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Rep, class _Period>
907*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
908*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
909*58b9f456SAndroid Build Coastguard Workertypename enable_if
910*58b9f456SAndroid Build Coastguard Worker<
911*58b9f456SAndroid Build Coastguard Worker    __is_duration<_ToDuration>::value,
912*58b9f456SAndroid Build Coastguard Worker    _ToDuration
913*58b9f456SAndroid Build Coastguard Worker>::type
914*58b9f456SAndroid Build Coastguard Workerduration_cast(const duration<_Rep, _Period>& __fd)
915*58b9f456SAndroid Build Coastguard Worker{
916*58b9f456SAndroid Build Coastguard Worker    return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
917*58b9f456SAndroid Build Coastguard Worker}
918*58b9f456SAndroid Build Coastguard Worker
919*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep>
920*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
921*58b9f456SAndroid Build Coastguard Worker
922*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
923*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep>
924*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
925*58b9f456SAndroid Build Coastguard Worker    = treat_as_floating_point<_Rep>::value;
926*58b9f456SAndroid Build Coastguard Worker#endif
927*58b9f456SAndroid Build Coastguard Worker
928*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep>
929*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS duration_values
930*58b9f456SAndroid Build Coastguard Worker{
931*58b9f456SAndroid Build Coastguard Workerpublic:
932*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);}
933*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max()  _NOEXCEPT {return numeric_limits<_Rep>::max();}
934*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min()  _NOEXCEPT {return numeric_limits<_Rep>::lowest();}
935*58b9f456SAndroid Build Coastguard Worker};
936*58b9f456SAndroid Build Coastguard Worker
937*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
938*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Rep, class _Period>
939*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
940*58b9f456SAndroid Build Coastguard Workertypename enable_if
941*58b9f456SAndroid Build Coastguard Worker<
942*58b9f456SAndroid Build Coastguard Worker    __is_duration<_ToDuration>::value,
943*58b9f456SAndroid Build Coastguard Worker    _ToDuration
944*58b9f456SAndroid Build Coastguard Worker>::type
945*58b9f456SAndroid Build Coastguard Workerfloor(const duration<_Rep, _Period>& __d)
946*58b9f456SAndroid Build Coastguard Worker{
947*58b9f456SAndroid Build Coastguard Worker    _ToDuration __t = duration_cast<_ToDuration>(__d);
948*58b9f456SAndroid Build Coastguard Worker    if (__t > __d)
949*58b9f456SAndroid Build Coastguard Worker        __t = __t - _ToDuration{1};
950*58b9f456SAndroid Build Coastguard Worker    return __t;
951*58b9f456SAndroid Build Coastguard Worker}
952*58b9f456SAndroid Build Coastguard Worker
953*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Rep, class _Period>
954*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
955*58b9f456SAndroid Build Coastguard Workertypename enable_if
956*58b9f456SAndroid Build Coastguard Worker<
957*58b9f456SAndroid Build Coastguard Worker    __is_duration<_ToDuration>::value,
958*58b9f456SAndroid Build Coastguard Worker    _ToDuration
959*58b9f456SAndroid Build Coastguard Worker>::type
960*58b9f456SAndroid Build Coastguard Workerceil(const duration<_Rep, _Period>& __d)
961*58b9f456SAndroid Build Coastguard Worker{
962*58b9f456SAndroid Build Coastguard Worker    _ToDuration __t = duration_cast<_ToDuration>(__d);
963*58b9f456SAndroid Build Coastguard Worker    if (__t < __d)
964*58b9f456SAndroid Build Coastguard Worker        __t = __t + _ToDuration{1};
965*58b9f456SAndroid Build Coastguard Worker    return __t;
966*58b9f456SAndroid Build Coastguard Worker}
967*58b9f456SAndroid Build Coastguard Worker
968*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Rep, class _Period>
969*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
970*58b9f456SAndroid Build Coastguard Workertypename enable_if
971*58b9f456SAndroid Build Coastguard Worker<
972*58b9f456SAndroid Build Coastguard Worker    __is_duration<_ToDuration>::value,
973*58b9f456SAndroid Build Coastguard Worker    _ToDuration
974*58b9f456SAndroid Build Coastguard Worker>::type
975*58b9f456SAndroid Build Coastguard Workerround(const duration<_Rep, _Period>& __d)
976*58b9f456SAndroid Build Coastguard Worker{
977*58b9f456SAndroid Build Coastguard Worker    _ToDuration __lower = floor<_ToDuration>(__d);
978*58b9f456SAndroid Build Coastguard Worker    _ToDuration __upper = __lower + _ToDuration{1};
979*58b9f456SAndroid Build Coastguard Worker    auto __lowerDiff = __d - __lower;
980*58b9f456SAndroid Build Coastguard Worker    auto __upperDiff = __upper - __d;
981*58b9f456SAndroid Build Coastguard Worker    if (__lowerDiff < __upperDiff)
982*58b9f456SAndroid Build Coastguard Worker        return __lower;
983*58b9f456SAndroid Build Coastguard Worker    if (__lowerDiff > __upperDiff)
984*58b9f456SAndroid Build Coastguard Worker        return __upper;
985*58b9f456SAndroid Build Coastguard Worker    return __lower.count() & 1 ? __upper : __lower;
986*58b9f456SAndroid Build Coastguard Worker}
987*58b9f456SAndroid Build Coastguard Worker#endif
988*58b9f456SAndroid Build Coastguard Worker
989*58b9f456SAndroid Build Coastguard Worker// duration
990*58b9f456SAndroid Build Coastguard Worker
991*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep, class _Period>
992*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS duration
993*58b9f456SAndroid Build Coastguard Worker{
994*58b9f456SAndroid Build Coastguard Worker    static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
995*58b9f456SAndroid Build Coastguard Worker    static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
996*58b9f456SAndroid Build Coastguard Worker    static_assert(_Period::num > 0, "duration period must be positive");
997*58b9f456SAndroid Build Coastguard Worker
998*58b9f456SAndroid Build Coastguard Worker    template <class _R1, class _R2>
999*58b9f456SAndroid Build Coastguard Worker    struct __no_overflow
1000*58b9f456SAndroid Build Coastguard Worker    {
1001*58b9f456SAndroid Build Coastguard Worker    private:
1002*58b9f456SAndroid Build Coastguard Worker        static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
1003*58b9f456SAndroid Build Coastguard Worker        static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
1004*58b9f456SAndroid Build Coastguard Worker        static const intmax_t __n1 = _R1::num / __gcd_n1_n2;
1005*58b9f456SAndroid Build Coastguard Worker        static const intmax_t __d1 = _R1::den / __gcd_d1_d2;
1006*58b9f456SAndroid Build Coastguard Worker        static const intmax_t __n2 = _R2::num / __gcd_n1_n2;
1007*58b9f456SAndroid Build Coastguard Worker        static const intmax_t __d2 = _R2::den / __gcd_d1_d2;
1008*58b9f456SAndroid Build Coastguard Worker        static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1);
1009*58b9f456SAndroid Build Coastguard Worker
1010*58b9f456SAndroid Build Coastguard Worker        template <intmax_t _Xp, intmax_t _Yp, bool __overflow>
1011*58b9f456SAndroid Build Coastguard Worker        struct __mul    // __overflow == false
1012*58b9f456SAndroid Build Coastguard Worker        {
1013*58b9f456SAndroid Build Coastguard Worker            static const intmax_t value = _Xp * _Yp;
1014*58b9f456SAndroid Build Coastguard Worker        };
1015*58b9f456SAndroid Build Coastguard Worker
1016*58b9f456SAndroid Build Coastguard Worker        template <intmax_t _Xp, intmax_t _Yp>
1017*58b9f456SAndroid Build Coastguard Worker        struct __mul<_Xp, _Yp, true>
1018*58b9f456SAndroid Build Coastguard Worker        {
1019*58b9f456SAndroid Build Coastguard Worker            static const intmax_t value = 1;
1020*58b9f456SAndroid Build Coastguard Worker        };
1021*58b9f456SAndroid Build Coastguard Worker
1022*58b9f456SAndroid Build Coastguard Worker    public:
1023*58b9f456SAndroid Build Coastguard Worker        static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1);
1024*58b9f456SAndroid Build Coastguard Worker        typedef ratio<__mul<__n1, __d2, !value>::value,
1025*58b9f456SAndroid Build Coastguard Worker                      __mul<__n2, __d1, !value>::value> type;
1026*58b9f456SAndroid Build Coastguard Worker    };
1027*58b9f456SAndroid Build Coastguard Worker
1028*58b9f456SAndroid Build Coastguard Workerpublic:
1029*58b9f456SAndroid Build Coastguard Worker    typedef _Rep rep;
1030*58b9f456SAndroid Build Coastguard Worker    typedef typename _Period::type period;
1031*58b9f456SAndroid Build Coastguard Workerprivate:
1032*58b9f456SAndroid Build Coastguard Worker    rep __rep_;
1033*58b9f456SAndroid Build Coastguard Workerpublic:
1034*58b9f456SAndroid Build Coastguard Worker
1035*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1036*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1037*58b9f456SAndroid Build Coastguard Worker        duration() = default;
1038*58b9f456SAndroid Build Coastguard Worker#else
1039*58b9f456SAndroid Build Coastguard Worker        duration() {}
1040*58b9f456SAndroid Build Coastguard Worker#endif
1041*58b9f456SAndroid Build Coastguard Worker
1042*58b9f456SAndroid Build Coastguard Worker    template <class _Rep2>
1043*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1044*58b9f456SAndroid Build Coastguard Worker        explicit duration(const _Rep2& __r,
1045*58b9f456SAndroid Build Coastguard Worker            typename enable_if
1046*58b9f456SAndroid Build Coastguard Worker            <
1047*58b9f456SAndroid Build Coastguard Worker               is_convertible<_Rep2, rep>::value &&
1048*58b9f456SAndroid Build Coastguard Worker               (treat_as_floating_point<rep>::value ||
1049*58b9f456SAndroid Build Coastguard Worker               !treat_as_floating_point<_Rep2>::value)
1050*58b9f456SAndroid Build Coastguard Worker            >::type* = 0)
1051*58b9f456SAndroid Build Coastguard Worker                : __rep_(__r) {}
1052*58b9f456SAndroid Build Coastguard Worker
1053*58b9f456SAndroid Build Coastguard Worker    // conversions
1054*58b9f456SAndroid Build Coastguard Worker    template <class _Rep2, class _Period2>
1055*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1056*58b9f456SAndroid Build Coastguard Worker        duration(const duration<_Rep2, _Period2>& __d,
1057*58b9f456SAndroid Build Coastguard Worker            typename enable_if
1058*58b9f456SAndroid Build Coastguard Worker            <
1059*58b9f456SAndroid Build Coastguard Worker                __no_overflow<_Period2, period>::value && (
1060*58b9f456SAndroid Build Coastguard Worker                treat_as_floating_point<rep>::value ||
1061*58b9f456SAndroid Build Coastguard Worker                (__no_overflow<_Period2, period>::type::den == 1 &&
1062*58b9f456SAndroid Build Coastguard Worker                 !treat_as_floating_point<_Rep2>::value))
1063*58b9f456SAndroid Build Coastguard Worker            >::type* = 0)
1064*58b9f456SAndroid Build Coastguard Worker                : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}
1065*58b9f456SAndroid Build Coastguard Worker
1066*58b9f456SAndroid Build Coastguard Worker    // observer
1067*58b9f456SAndroid Build Coastguard Worker
1068*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
1069*58b9f456SAndroid Build Coastguard Worker
1070*58b9f456SAndroid Build Coastguard Worker    // arithmetic
1071*58b9f456SAndroid Build Coastguard Worker
1072*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}
1073*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);}
1074*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++()      {++__rep_; return *this;}
1075*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration  operator++(int)   {return duration(__rep_++);}
1076*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--()      {--__rep_; return *this;}
1077*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration  operator--(int)   {return duration(__rep_--);}
1078*58b9f456SAndroid Build Coastguard Worker
1079*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
1080*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
1081*58b9f456SAndroid Build Coastguard Worker
1082*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
1083*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
1084*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
1085*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
1086*58b9f456SAndroid Build Coastguard Worker
1087*58b9f456SAndroid Build Coastguard Worker    // special values
1088*58b9f456SAndroid Build Coastguard Worker
1089*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values<rep>::zero());}
1090*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min()  _NOEXCEPT {return duration(duration_values<rep>::min());}
1091*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max()  _NOEXCEPT {return duration(duration_values<rep>::max());}
1092*58b9f456SAndroid Build Coastguard Worker};
1093*58b9f456SAndroid Build Coastguard Worker
1094*58b9f456SAndroid Build Coastguard Workertypedef duration<long long,         nano> nanoseconds;
1095*58b9f456SAndroid Build Coastguard Workertypedef duration<long long,        micro> microseconds;
1096*58b9f456SAndroid Build Coastguard Workertypedef duration<long long,        milli> milliseconds;
1097*58b9f456SAndroid Build Coastguard Workertypedef duration<long long              > seconds;
1098*58b9f456SAndroid Build Coastguard Workertypedef duration<     long, ratio<  60> > minutes;
1099*58b9f456SAndroid Build Coastguard Workertypedef duration<     long, ratio<3600> > hours;
1100*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17
1101*58b9f456SAndroid Build Coastguard Workertypedef duration<     int, ratio_multiply<ratio<24>, hours::period>>         days;
1102*58b9f456SAndroid Build Coastguard Workertypedef duration<     int, ratio_multiply<ratio<7>,   days::period>>         weeks;
1103*58b9f456SAndroid Build Coastguard Workertypedef duration<     int, ratio_multiply<ratio<146097, 400>, days::period>> years;
1104*58b9f456SAndroid Build Coastguard Workertypedef duration<     int, ratio_divide<years::period, ratio<12>>>           months;
1105*58b9f456SAndroid Build Coastguard Worker#endif
1106*58b9f456SAndroid Build Coastguard Worker// Duration ==
1107*58b9f456SAndroid Build Coastguard Worker
1108*58b9f456SAndroid Build Coastguard Workertemplate <class _LhsDuration, class _RhsDuration>
1109*58b9f456SAndroid Build Coastguard Workerstruct __duration_eq
1110*58b9f456SAndroid Build Coastguard Worker{
1111*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1112*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
1113*58b9f456SAndroid Build Coastguard Worker        {
1114*58b9f456SAndroid Build Coastguard Worker            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
1115*58b9f456SAndroid Build Coastguard Worker            return _Ct(__lhs).count() == _Ct(__rhs).count();
1116*58b9f456SAndroid Build Coastguard Worker        }
1117*58b9f456SAndroid Build Coastguard Worker};
1118*58b9f456SAndroid Build Coastguard Worker
1119*58b9f456SAndroid Build Coastguard Workertemplate <class _LhsDuration>
1120*58b9f456SAndroid Build Coastguard Workerstruct __duration_eq<_LhsDuration, _LhsDuration>
1121*58b9f456SAndroid Build Coastguard Worker{
1122*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1123*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
1124*58b9f456SAndroid Build Coastguard Worker        {return __lhs.count() == __rhs.count();}
1125*58b9f456SAndroid Build Coastguard Worker};
1126*58b9f456SAndroid Build Coastguard Worker
1127*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1128*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1129*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1130*58b9f456SAndroid Build Coastguard Workerbool
1131*58b9f456SAndroid Build Coastguard Workeroperator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1132*58b9f456SAndroid Build Coastguard Worker{
1133*58b9f456SAndroid Build Coastguard Worker    return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
1134*58b9f456SAndroid Build Coastguard Worker}
1135*58b9f456SAndroid Build Coastguard Worker
1136*58b9f456SAndroid Build Coastguard Worker// Duration !=
1137*58b9f456SAndroid Build Coastguard Worker
1138*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1139*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1140*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1141*58b9f456SAndroid Build Coastguard Workerbool
1142*58b9f456SAndroid Build Coastguard Workeroperator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1143*58b9f456SAndroid Build Coastguard Worker{
1144*58b9f456SAndroid Build Coastguard Worker    return !(__lhs == __rhs);
1145*58b9f456SAndroid Build Coastguard Worker}
1146*58b9f456SAndroid Build Coastguard Worker
1147*58b9f456SAndroid Build Coastguard Worker// Duration <
1148*58b9f456SAndroid Build Coastguard Worker
1149*58b9f456SAndroid Build Coastguard Workertemplate <class _LhsDuration, class _RhsDuration>
1150*58b9f456SAndroid Build Coastguard Workerstruct __duration_lt
1151*58b9f456SAndroid Build Coastguard Worker{
1152*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1153*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
1154*58b9f456SAndroid Build Coastguard Worker        {
1155*58b9f456SAndroid Build Coastguard Worker            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
1156*58b9f456SAndroid Build Coastguard Worker            return _Ct(__lhs).count() < _Ct(__rhs).count();
1157*58b9f456SAndroid Build Coastguard Worker        }
1158*58b9f456SAndroid Build Coastguard Worker};
1159*58b9f456SAndroid Build Coastguard Worker
1160*58b9f456SAndroid Build Coastguard Workertemplate <class _LhsDuration>
1161*58b9f456SAndroid Build Coastguard Workerstruct __duration_lt<_LhsDuration, _LhsDuration>
1162*58b9f456SAndroid Build Coastguard Worker{
1163*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1164*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
1165*58b9f456SAndroid Build Coastguard Worker        {return __lhs.count() < __rhs.count();}
1166*58b9f456SAndroid Build Coastguard Worker};
1167*58b9f456SAndroid Build Coastguard Worker
1168*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1169*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1170*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1171*58b9f456SAndroid Build Coastguard Workerbool
1172*58b9f456SAndroid Build Coastguard Workeroperator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1173*58b9f456SAndroid Build Coastguard Worker{
1174*58b9f456SAndroid Build Coastguard Worker    return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
1175*58b9f456SAndroid Build Coastguard Worker}
1176*58b9f456SAndroid Build Coastguard Worker
1177*58b9f456SAndroid Build Coastguard Worker// Duration >
1178*58b9f456SAndroid Build Coastguard Worker
1179*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1180*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1181*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1182*58b9f456SAndroid Build Coastguard Workerbool
1183*58b9f456SAndroid Build Coastguard Workeroperator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1184*58b9f456SAndroid Build Coastguard Worker{
1185*58b9f456SAndroid Build Coastguard Worker    return __rhs < __lhs;
1186*58b9f456SAndroid Build Coastguard Worker}
1187*58b9f456SAndroid Build Coastguard Worker
1188*58b9f456SAndroid Build Coastguard Worker// Duration <=
1189*58b9f456SAndroid Build Coastguard Worker
1190*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1191*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1192*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1193*58b9f456SAndroid Build Coastguard Workerbool
1194*58b9f456SAndroid Build Coastguard Workeroperator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1195*58b9f456SAndroid Build Coastguard Worker{
1196*58b9f456SAndroid Build Coastguard Worker    return !(__rhs < __lhs);
1197*58b9f456SAndroid Build Coastguard Worker}
1198*58b9f456SAndroid Build Coastguard Worker
1199*58b9f456SAndroid Build Coastguard Worker// Duration >=
1200*58b9f456SAndroid Build Coastguard Worker
1201*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1202*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1203*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1204*58b9f456SAndroid Build Coastguard Workerbool
1205*58b9f456SAndroid Build Coastguard Workeroperator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1206*58b9f456SAndroid Build Coastguard Worker{
1207*58b9f456SAndroid Build Coastguard Worker    return !(__lhs < __rhs);
1208*58b9f456SAndroid Build Coastguard Worker}
1209*58b9f456SAndroid Build Coastguard Worker
1210*58b9f456SAndroid Build Coastguard Worker// Duration +
1211*58b9f456SAndroid Build Coastguard Worker
1212*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1213*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1214*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1215*58b9f456SAndroid Build Coastguard Workertypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
1216*58b9f456SAndroid Build Coastguard Workeroperator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1217*58b9f456SAndroid Build Coastguard Worker{
1218*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
1219*58b9f456SAndroid Build Coastguard Worker    return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
1220*58b9f456SAndroid Build Coastguard Worker}
1221*58b9f456SAndroid Build Coastguard Worker
1222*58b9f456SAndroid Build Coastguard Worker// Duration -
1223*58b9f456SAndroid Build Coastguard Worker
1224*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1225*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1226*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1227*58b9f456SAndroid Build Coastguard Workertypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
1228*58b9f456SAndroid Build Coastguard Workeroperator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1229*58b9f456SAndroid Build Coastguard Worker{
1230*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
1231*58b9f456SAndroid Build Coastguard Worker    return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
1232*58b9f456SAndroid Build Coastguard Worker}
1233*58b9f456SAndroid Build Coastguard Worker
1234*58b9f456SAndroid Build Coastguard Worker// Duration *
1235*58b9f456SAndroid Build Coastguard Worker
1236*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period, class _Rep2>
1237*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1238*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1239*58b9f456SAndroid Build Coastguard Workertypename enable_if
1240*58b9f456SAndroid Build Coastguard Worker<
1241*58b9f456SAndroid Build Coastguard Worker    is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
1242*58b9f456SAndroid Build Coastguard Worker    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
1243*58b9f456SAndroid Build Coastguard Worker>::type
1244*58b9f456SAndroid Build Coastguard Workeroperator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
1245*58b9f456SAndroid Build Coastguard Worker{
1246*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
1247*58b9f456SAndroid Build Coastguard Worker    typedef duration<_Cr, _Period> _Cd;
1248*58b9f456SAndroid Build Coastguard Worker    return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
1249*58b9f456SAndroid Build Coastguard Worker}
1250*58b9f456SAndroid Build Coastguard Worker
1251*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period, class _Rep2>
1252*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1253*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1254*58b9f456SAndroid Build Coastguard Workertypename enable_if
1255*58b9f456SAndroid Build Coastguard Worker<
1256*58b9f456SAndroid Build Coastguard Worker    is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
1257*58b9f456SAndroid Build Coastguard Worker    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
1258*58b9f456SAndroid Build Coastguard Worker>::type
1259*58b9f456SAndroid Build Coastguard Workeroperator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
1260*58b9f456SAndroid Build Coastguard Worker{
1261*58b9f456SAndroid Build Coastguard Worker    return __d * __s;
1262*58b9f456SAndroid Build Coastguard Worker}
1263*58b9f456SAndroid Build Coastguard Worker
1264*58b9f456SAndroid Build Coastguard Worker// Duration /
1265*58b9f456SAndroid Build Coastguard Worker
1266*58b9f456SAndroid Build Coastguard Workertemplate <class _Duration, class _Rep, bool = __is_duration<_Rep>::value>
1267*58b9f456SAndroid Build Coastguard Workerstruct __duration_divide_result
1268*58b9f456SAndroid Build Coastguard Worker{
1269*58b9f456SAndroid Build Coastguard Worker};
1270*58b9f456SAndroid Build Coastguard Worker
1271*58b9f456SAndroid Build Coastguard Workertemplate <class _Duration, class _Rep2,
1272*58b9f456SAndroid Build Coastguard Worker    bool = is_convertible<_Rep2,
1273*58b9f456SAndroid Build Coastguard Worker                          typename common_type<typename _Duration::rep, _Rep2>::type>::value>
1274*58b9f456SAndroid Build Coastguard Workerstruct __duration_divide_imp
1275*58b9f456SAndroid Build Coastguard Worker{
1276*58b9f456SAndroid Build Coastguard Worker};
1277*58b9f456SAndroid Build Coastguard Worker
1278*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period, class _Rep2>
1279*58b9f456SAndroid Build Coastguard Workerstruct __duration_divide_imp<duration<_Rep1, _Period>, _Rep2, true>
1280*58b9f456SAndroid Build Coastguard Worker{
1281*58b9f456SAndroid Build Coastguard Worker    typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> type;
1282*58b9f456SAndroid Build Coastguard Worker};
1283*58b9f456SAndroid Build Coastguard Worker
1284*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period, class _Rep2>
1285*58b9f456SAndroid Build Coastguard Workerstruct __duration_divide_result<duration<_Rep1, _Period>, _Rep2, false>
1286*58b9f456SAndroid Build Coastguard Worker    : __duration_divide_imp<duration<_Rep1, _Period>, _Rep2>
1287*58b9f456SAndroid Build Coastguard Worker{
1288*58b9f456SAndroid Build Coastguard Worker};
1289*58b9f456SAndroid Build Coastguard Worker
1290*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period, class _Rep2>
1291*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1292*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1293*58b9f456SAndroid Build Coastguard Workertypename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
1294*58b9f456SAndroid Build Coastguard Workeroperator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
1295*58b9f456SAndroid Build Coastguard Worker{
1296*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
1297*58b9f456SAndroid Build Coastguard Worker    typedef duration<_Cr, _Period> _Cd;
1298*58b9f456SAndroid Build Coastguard Worker    return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
1299*58b9f456SAndroid Build Coastguard Worker}
1300*58b9f456SAndroid Build Coastguard Worker
1301*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1302*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1303*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1304*58b9f456SAndroid Build Coastguard Workertypename common_type<_Rep1, _Rep2>::type
1305*58b9f456SAndroid Build Coastguard Workeroperator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1306*58b9f456SAndroid Build Coastguard Worker{
1307*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
1308*58b9f456SAndroid Build Coastguard Worker    return _Ct(__lhs).count() / _Ct(__rhs).count();
1309*58b9f456SAndroid Build Coastguard Worker}
1310*58b9f456SAndroid Build Coastguard Worker
1311*58b9f456SAndroid Build Coastguard Worker// Duration %
1312*58b9f456SAndroid Build Coastguard Worker
1313*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period, class _Rep2>
1314*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1315*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1316*58b9f456SAndroid Build Coastguard Workertypename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
1317*58b9f456SAndroid Build Coastguard Workeroperator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
1318*58b9f456SAndroid Build Coastguard Worker{
1319*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
1320*58b9f456SAndroid Build Coastguard Worker    typedef duration<_Cr, _Period> _Cd;
1321*58b9f456SAndroid Build Coastguard Worker    return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
1322*58b9f456SAndroid Build Coastguard Worker}
1323*58b9f456SAndroid Build Coastguard Worker
1324*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
1325*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1326*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR
1327*58b9f456SAndroid Build Coastguard Workertypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
1328*58b9f456SAndroid Build Coastguard Workeroperator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1329*58b9f456SAndroid Build Coastguard Worker{
1330*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
1331*58b9f456SAndroid Build Coastguard Worker    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
1332*58b9f456SAndroid Build Coastguard Worker    return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
1333*58b9f456SAndroid Build Coastguard Worker}
1334*58b9f456SAndroid Build Coastguard Worker
1335*58b9f456SAndroid Build Coastguard Worker//////////////////////////////////////////////////////////
1336*58b9f456SAndroid Build Coastguard Worker///////////////////// time_point /////////////////////////
1337*58b9f456SAndroid Build Coastguard Worker//////////////////////////////////////////////////////////
1338*58b9f456SAndroid Build Coastguard Worker
1339*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration = typename _Clock::duration>
1340*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS time_point
1341*58b9f456SAndroid Build Coastguard Worker{
1342*58b9f456SAndroid Build Coastguard Worker    static_assert(__is_duration<_Duration>::value,
1343*58b9f456SAndroid Build Coastguard Worker                  "Second template parameter of time_point must be a std::chrono::duration");
1344*58b9f456SAndroid Build Coastguard Workerpublic:
1345*58b9f456SAndroid Build Coastguard Worker    typedef _Clock                    clock;
1346*58b9f456SAndroid Build Coastguard Worker    typedef _Duration                 duration;
1347*58b9f456SAndroid Build Coastguard Worker    typedef typename duration::rep    rep;
1348*58b9f456SAndroid Build Coastguard Worker    typedef typename duration::period period;
1349*58b9f456SAndroid Build Coastguard Workerprivate:
1350*58b9f456SAndroid Build Coastguard Worker    duration __d_;
1351*58b9f456SAndroid Build Coastguard Worker
1352*58b9f456SAndroid Build Coastguard Workerpublic:
1353*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}
1354*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}
1355*58b9f456SAndroid Build Coastguard Worker
1356*58b9f456SAndroid Build Coastguard Worker    // conversions
1357*58b9f456SAndroid Build Coastguard Worker    template <class _Duration2>
1358*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1359*58b9f456SAndroid Build Coastguard Worker    time_point(const time_point<clock, _Duration2>& t,
1360*58b9f456SAndroid Build Coastguard Worker        typename enable_if
1361*58b9f456SAndroid Build Coastguard Worker        <
1362*58b9f456SAndroid Build Coastguard Worker            is_convertible<_Duration2, duration>::value
1363*58b9f456SAndroid Build Coastguard Worker        >::type* = 0)
1364*58b9f456SAndroid Build Coastguard Worker            : __d_(t.time_since_epoch()) {}
1365*58b9f456SAndroid Build Coastguard Worker
1366*58b9f456SAndroid Build Coastguard Worker    // observer
1367*58b9f456SAndroid Build Coastguard Worker
1368*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
1369*58b9f456SAndroid Build Coastguard Worker
1370*58b9f456SAndroid Build Coastguard Worker    // arithmetic
1371*58b9f456SAndroid Build Coastguard Worker
1372*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
1373*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
1374*58b9f456SAndroid Build Coastguard Worker
1375*58b9f456SAndroid Build Coastguard Worker    // special values
1376*58b9f456SAndroid Build Coastguard Worker
1377*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT {return time_point(duration::min());}
1378*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT {return time_point(duration::max());}
1379*58b9f456SAndroid Build Coastguard Worker};
1380*58b9f456SAndroid Build Coastguard Worker
1381*58b9f456SAndroid Build Coastguard Worker} // chrono
1382*58b9f456SAndroid Build Coastguard Worker
1383*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1384*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
1385*58b9f456SAndroid Build Coastguard Worker                                         chrono::time_point<_Clock, _Duration2> >
1386*58b9f456SAndroid Build Coastguard Worker{
1387*58b9f456SAndroid Build Coastguard Worker    typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
1388*58b9f456SAndroid Build Coastguard Worker};
1389*58b9f456SAndroid Build Coastguard Worker
1390*58b9f456SAndroid Build Coastguard Workernamespace chrono {
1391*58b9f456SAndroid Build Coastguard Worker
1392*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Clock, class _Duration>
1393*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1394*58b9f456SAndroid Build Coastguard Workertime_point<_Clock, _ToDuration>
1395*58b9f456SAndroid Build Coastguard Workertime_point_cast(const time_point<_Clock, _Duration>& __t)
1396*58b9f456SAndroid Build Coastguard Worker{
1397*58b9f456SAndroid Build Coastguard Worker    return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
1398*58b9f456SAndroid Build Coastguard Worker}
1399*58b9f456SAndroid Build Coastguard Worker
1400*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1401*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Clock, class _Duration>
1402*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1403*58b9f456SAndroid Build Coastguard Workertypename enable_if
1404*58b9f456SAndroid Build Coastguard Worker<
1405*58b9f456SAndroid Build Coastguard Worker    __is_duration<_ToDuration>::value,
1406*58b9f456SAndroid Build Coastguard Worker    time_point<_Clock, _ToDuration>
1407*58b9f456SAndroid Build Coastguard Worker>::type
1408*58b9f456SAndroid Build Coastguard Workerfloor(const time_point<_Clock, _Duration>& __t)
1409*58b9f456SAndroid Build Coastguard Worker{
1410*58b9f456SAndroid Build Coastguard Worker    return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())};
1411*58b9f456SAndroid Build Coastguard Worker}
1412*58b9f456SAndroid Build Coastguard Worker
1413*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Clock, class _Duration>
1414*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1415*58b9f456SAndroid Build Coastguard Workertypename enable_if
1416*58b9f456SAndroid Build Coastguard Worker<
1417*58b9f456SAndroid Build Coastguard Worker    __is_duration<_ToDuration>::value,
1418*58b9f456SAndroid Build Coastguard Worker    time_point<_Clock, _ToDuration>
1419*58b9f456SAndroid Build Coastguard Worker>::type
1420*58b9f456SAndroid Build Coastguard Workerceil(const time_point<_Clock, _Duration>& __t)
1421*58b9f456SAndroid Build Coastguard Worker{
1422*58b9f456SAndroid Build Coastguard Worker    return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())};
1423*58b9f456SAndroid Build Coastguard Worker}
1424*58b9f456SAndroid Build Coastguard Worker
1425*58b9f456SAndroid Build Coastguard Workertemplate <class _ToDuration, class _Clock, class _Duration>
1426*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1427*58b9f456SAndroid Build Coastguard Workertypename enable_if
1428*58b9f456SAndroid Build Coastguard Worker<
1429*58b9f456SAndroid Build Coastguard Worker    __is_duration<_ToDuration>::value,
1430*58b9f456SAndroid Build Coastguard Worker    time_point<_Clock, _ToDuration>
1431*58b9f456SAndroid Build Coastguard Worker>::type
1432*58b9f456SAndroid Build Coastguard Workerround(const time_point<_Clock, _Duration>& __t)
1433*58b9f456SAndroid Build Coastguard Worker{
1434*58b9f456SAndroid Build Coastguard Worker    return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())};
1435*58b9f456SAndroid Build Coastguard Worker}
1436*58b9f456SAndroid Build Coastguard Worker
1437*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep, class _Period>
1438*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
1439*58b9f456SAndroid Build Coastguard Workertypename enable_if
1440*58b9f456SAndroid Build Coastguard Worker<
1441*58b9f456SAndroid Build Coastguard Worker    numeric_limits<_Rep>::is_signed,
1442*58b9f456SAndroid Build Coastguard Worker    duration<_Rep, _Period>
1443*58b9f456SAndroid Build Coastguard Worker>::type
1444*58b9f456SAndroid Build Coastguard Workerabs(duration<_Rep, _Period> __d)
1445*58b9f456SAndroid Build Coastguard Worker{
1446*58b9f456SAndroid Build Coastguard Worker    return __d >= __d.zero() ? __d : -__d;
1447*58b9f456SAndroid Build Coastguard Worker}
1448*58b9f456SAndroid Build Coastguard Worker#endif
1449*58b9f456SAndroid Build Coastguard Worker
1450*58b9f456SAndroid Build Coastguard Worker// time_point ==
1451*58b9f456SAndroid Build Coastguard Worker
1452*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1453*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1454*58b9f456SAndroid Build Coastguard Workerbool
1455*58b9f456SAndroid Build Coastguard Workeroperator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1456*58b9f456SAndroid Build Coastguard Worker{
1457*58b9f456SAndroid Build Coastguard Worker    return __lhs.time_since_epoch() == __rhs.time_since_epoch();
1458*58b9f456SAndroid Build Coastguard Worker}
1459*58b9f456SAndroid Build Coastguard Worker
1460*58b9f456SAndroid Build Coastguard Worker// time_point !=
1461*58b9f456SAndroid Build Coastguard Worker
1462*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1463*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1464*58b9f456SAndroid Build Coastguard Workerbool
1465*58b9f456SAndroid Build Coastguard Workeroperator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1466*58b9f456SAndroid Build Coastguard Worker{
1467*58b9f456SAndroid Build Coastguard Worker    return !(__lhs == __rhs);
1468*58b9f456SAndroid Build Coastguard Worker}
1469*58b9f456SAndroid Build Coastguard Worker
1470*58b9f456SAndroid Build Coastguard Worker// time_point <
1471*58b9f456SAndroid Build Coastguard Worker
1472*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1473*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1474*58b9f456SAndroid Build Coastguard Workerbool
1475*58b9f456SAndroid Build Coastguard Workeroperator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1476*58b9f456SAndroid Build Coastguard Worker{
1477*58b9f456SAndroid Build Coastguard Worker    return __lhs.time_since_epoch() < __rhs.time_since_epoch();
1478*58b9f456SAndroid Build Coastguard Worker}
1479*58b9f456SAndroid Build Coastguard Worker
1480*58b9f456SAndroid Build Coastguard Worker// time_point >
1481*58b9f456SAndroid Build Coastguard Worker
1482*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1483*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1484*58b9f456SAndroid Build Coastguard Workerbool
1485*58b9f456SAndroid Build Coastguard Workeroperator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1486*58b9f456SAndroid Build Coastguard Worker{
1487*58b9f456SAndroid Build Coastguard Worker    return __rhs < __lhs;
1488*58b9f456SAndroid Build Coastguard Worker}
1489*58b9f456SAndroid Build Coastguard Worker
1490*58b9f456SAndroid Build Coastguard Worker// time_point <=
1491*58b9f456SAndroid Build Coastguard Worker
1492*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1493*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1494*58b9f456SAndroid Build Coastguard Workerbool
1495*58b9f456SAndroid Build Coastguard Workeroperator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1496*58b9f456SAndroid Build Coastguard Worker{
1497*58b9f456SAndroid Build Coastguard Worker    return !(__rhs < __lhs);
1498*58b9f456SAndroid Build Coastguard Worker}
1499*58b9f456SAndroid Build Coastguard Worker
1500*58b9f456SAndroid Build Coastguard Worker// time_point >=
1501*58b9f456SAndroid Build Coastguard Worker
1502*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1503*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1504*58b9f456SAndroid Build Coastguard Workerbool
1505*58b9f456SAndroid Build Coastguard Workeroperator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1506*58b9f456SAndroid Build Coastguard Worker{
1507*58b9f456SAndroid Build Coastguard Worker    return !(__lhs < __rhs);
1508*58b9f456SAndroid Build Coastguard Worker}
1509*58b9f456SAndroid Build Coastguard Worker
1510*58b9f456SAndroid Build Coastguard Worker// time_point operator+(time_point x, duration y);
1511*58b9f456SAndroid Build Coastguard Worker
1512*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Rep2, class _Period2>
1513*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1514*58b9f456SAndroid Build Coastguard Workertime_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
1515*58b9f456SAndroid Build Coastguard Workeroperator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1516*58b9f456SAndroid Build Coastguard Worker{
1517*58b9f456SAndroid Build Coastguard Worker    typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
1518*58b9f456SAndroid Build Coastguard Worker    return _Tr (__lhs.time_since_epoch() + __rhs);
1519*58b9f456SAndroid Build Coastguard Worker}
1520*58b9f456SAndroid Build Coastguard Worker
1521*58b9f456SAndroid Build Coastguard Worker// time_point operator+(duration x, time_point y);
1522*58b9f456SAndroid Build Coastguard Worker
1523*58b9f456SAndroid Build Coastguard Workertemplate <class _Rep1, class _Period1, class _Clock, class _Duration2>
1524*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1525*58b9f456SAndroid Build Coastguard Workertime_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
1526*58b9f456SAndroid Build Coastguard Workeroperator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1527*58b9f456SAndroid Build Coastguard Worker{
1528*58b9f456SAndroid Build Coastguard Worker    return __rhs + __lhs;
1529*58b9f456SAndroid Build Coastguard Worker}
1530*58b9f456SAndroid Build Coastguard Worker
1531*58b9f456SAndroid Build Coastguard Worker// time_point operator-(time_point x, duration y);
1532*58b9f456SAndroid Build Coastguard Worker
1533*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Rep2, class _Period2>
1534*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1535*58b9f456SAndroid Build Coastguard Workertime_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
1536*58b9f456SAndroid Build Coastguard Workeroperator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
1537*58b9f456SAndroid Build Coastguard Worker{
1538*58b9f456SAndroid Build Coastguard Worker    typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret;
1539*58b9f456SAndroid Build Coastguard Worker    return _Ret(__lhs.time_since_epoch() -__rhs);
1540*58b9f456SAndroid Build Coastguard Worker}
1541*58b9f456SAndroid Build Coastguard Worker
1542*58b9f456SAndroid Build Coastguard Worker// duration operator-(time_point x, time_point y);
1543*58b9f456SAndroid Build Coastguard Worker
1544*58b9f456SAndroid Build Coastguard Workertemplate <class _Clock, class _Duration1, class _Duration2>
1545*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1546*58b9f456SAndroid Build Coastguard Workertypename common_type<_Duration1, _Duration2>::type
1547*58b9f456SAndroid Build Coastguard Workeroperator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
1548*58b9f456SAndroid Build Coastguard Worker{
1549*58b9f456SAndroid Build Coastguard Worker    return __lhs.time_since_epoch() - __rhs.time_since_epoch();
1550*58b9f456SAndroid Build Coastguard Worker}
1551*58b9f456SAndroid Build Coastguard Worker
1552*58b9f456SAndroid Build Coastguard Worker//////////////////////////////////////////////////////////
1553*58b9f456SAndroid Build Coastguard Worker/////////////////////// clocks ///////////////////////////
1554*58b9f456SAndroid Build Coastguard Worker//////////////////////////////////////////////////////////
1555*58b9f456SAndroid Build Coastguard Worker
1556*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS system_clock
1557*58b9f456SAndroid Build Coastguard Worker{
1558*58b9f456SAndroid Build Coastguard Workerpublic:
1559*58b9f456SAndroid Build Coastguard Worker    typedef microseconds                     duration;
1560*58b9f456SAndroid Build Coastguard Worker    typedef duration::rep                    rep;
1561*58b9f456SAndroid Build Coastguard Worker    typedef duration::period                 period;
1562*58b9f456SAndroid Build Coastguard Worker    typedef chrono::time_point<system_clock> time_point;
1563*58b9f456SAndroid Build Coastguard Worker    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
1564*58b9f456SAndroid Build Coastguard Worker
1565*58b9f456SAndroid Build Coastguard Worker    static time_point now() _NOEXCEPT;
1566*58b9f456SAndroid Build Coastguard Worker    static time_t     to_time_t  (const time_point& __t) _NOEXCEPT;
1567*58b9f456SAndroid Build Coastguard Worker    static time_point from_time_t(time_t __t) _NOEXCEPT;
1568*58b9f456SAndroid Build Coastguard Worker};
1569*58b9f456SAndroid Build Coastguard Worker
1570*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
1571*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS steady_clock
1572*58b9f456SAndroid Build Coastguard Worker{
1573*58b9f456SAndroid Build Coastguard Workerpublic:
1574*58b9f456SAndroid Build Coastguard Worker    typedef nanoseconds                                   duration;
1575*58b9f456SAndroid Build Coastguard Worker    typedef duration::rep                                 rep;
1576*58b9f456SAndroid Build Coastguard Worker    typedef duration::period                              period;
1577*58b9f456SAndroid Build Coastguard Worker    typedef chrono::time_point<steady_clock, duration>    time_point;
1578*58b9f456SAndroid Build Coastguard Worker    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true;
1579*58b9f456SAndroid Build Coastguard Worker
1580*58b9f456SAndroid Build Coastguard Worker    static time_point now() _NOEXCEPT;
1581*58b9f456SAndroid Build Coastguard Worker};
1582*58b9f456SAndroid Build Coastguard Worker
1583*58b9f456SAndroid Build Coastguard Workertypedef steady_clock high_resolution_clock;
1584*58b9f456SAndroid Build Coastguard Worker#else
1585*58b9f456SAndroid Build Coastguard Workertypedef system_clock high_resolution_clock;
1586*58b9f456SAndroid Build Coastguard Worker#endif
1587*58b9f456SAndroid Build Coastguard Worker
1588*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17
1589*58b9f456SAndroid Build Coastguard Worker// [time.clock.file], type file_clock
1590*58b9f456SAndroid Build Coastguard Workerusing file_clock = _VSTD_FS::_FilesystemClock;
1591*58b9f456SAndroid Build Coastguard Worker
1592*58b9f456SAndroid Build Coastguard Workertemplate<class _Duration>
1593*58b9f456SAndroid Build Coastguard Workerusing file_time = time_point<file_clock, _Duration>;
1594*58b9f456SAndroid Build Coastguard Worker
1595*58b9f456SAndroid Build Coastguard Worker
1596*58b9f456SAndroid Build Coastguard Workertemplate <class _Duration>
1597*58b9f456SAndroid Build Coastguard Workerusing sys_time    = time_point<system_clock, _Duration>;
1598*58b9f456SAndroid Build Coastguard Workerusing sys_seconds = sys_time<seconds>;
1599*58b9f456SAndroid Build Coastguard Workerusing sys_days    = sys_time<days>;
1600*58b9f456SAndroid Build Coastguard Worker
1601*58b9f456SAndroid Build Coastguard Workerstruct local_t {};
1602*58b9f456SAndroid Build Coastguard Workertemplate<class Duration>
1603*58b9f456SAndroid Build Coastguard Workerusing local_time  = time_point<local_t, Duration>;
1604*58b9f456SAndroid Build Coastguard Workerusing local_seconds = local_time<seconds>;
1605*58b9f456SAndroid Build Coastguard Workerusing local_days    = local_time<days>;
1606*58b9f456SAndroid Build Coastguard Worker
1607*58b9f456SAndroid Build Coastguard Worker
1608*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TYPE_VIS last_spec { explicit last_spec() = default; };
1609*58b9f456SAndroid Build Coastguard Worker
1610*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS day {
1611*58b9f456SAndroid Build Coastguard Workerprivate:
1612*58b9f456SAndroid Build Coastguard Worker    unsigned char __d;
1613*58b9f456SAndroid Build Coastguard Workerpublic:
1614*58b9f456SAndroid Build Coastguard Worker    day() = default;
1615*58b9f456SAndroid Build Coastguard Worker    explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
1616*58b9f456SAndroid Build Coastguard Worker    inline constexpr day& operator++()    noexcept { ++__d; return *this; }
1617*58b9f456SAndroid Build Coastguard Worker    inline constexpr day  operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
1618*58b9f456SAndroid Build Coastguard Worker    inline constexpr day& operator--()    noexcept { --__d; return *this; }
1619*58b9f456SAndroid Build Coastguard Worker    inline constexpr day  operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
1620*58b9f456SAndroid Build Coastguard Worker           constexpr day& operator+=(const days& __dd) noexcept;
1621*58b9f456SAndroid Build Coastguard Worker           constexpr day& operator-=(const days& __dd) noexcept;
1622*58b9f456SAndroid Build Coastguard Worker    explicit inline constexpr operator unsigned() const noexcept { return __d; }
1623*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
1624*58b9f456SAndroid Build Coastguard Worker  };
1625*58b9f456SAndroid Build Coastguard Worker
1626*58b9f456SAndroid Build Coastguard Worker
1627*58b9f456SAndroid Build Coastguard Workerinline constexpr
1628*58b9f456SAndroid Build Coastguard Workerbool operator==(const day& __lhs, const day& __rhs) noexcept
1629*58b9f456SAndroid Build Coastguard Worker{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
1630*58b9f456SAndroid Build Coastguard Worker
1631*58b9f456SAndroid Build Coastguard Workerinline constexpr
1632*58b9f456SAndroid Build Coastguard Workerbool operator!=(const day& __lhs, const day& __rhs) noexcept
1633*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
1634*58b9f456SAndroid Build Coastguard Worker
1635*58b9f456SAndroid Build Coastguard Workerinline constexpr
1636*58b9f456SAndroid Build Coastguard Workerbool operator< (const day& __lhs, const day& __rhs) noexcept
1637*58b9f456SAndroid Build Coastguard Worker{ return static_cast<unsigned>(__lhs) <  static_cast<unsigned>(__rhs); }
1638*58b9f456SAndroid Build Coastguard Worker
1639*58b9f456SAndroid Build Coastguard Workerinline constexpr
1640*58b9f456SAndroid Build Coastguard Workerbool operator> (const day& __lhs, const day& __rhs) noexcept
1641*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
1642*58b9f456SAndroid Build Coastguard Worker
1643*58b9f456SAndroid Build Coastguard Workerinline constexpr
1644*58b9f456SAndroid Build Coastguard Workerbool operator<=(const day& __lhs, const day& __rhs) noexcept
1645*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs);}
1646*58b9f456SAndroid Build Coastguard Worker
1647*58b9f456SAndroid Build Coastguard Workerinline constexpr
1648*58b9f456SAndroid Build Coastguard Workerbool operator>=(const day& __lhs, const day& __rhs) noexcept
1649*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
1650*58b9f456SAndroid Build Coastguard Worker
1651*58b9f456SAndroid Build Coastguard Workerinline constexpr
1652*58b9f456SAndroid Build Coastguard Workerday operator+ (const day& __lhs, const days& __rhs) noexcept
1653*58b9f456SAndroid Build Coastguard Worker{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
1654*58b9f456SAndroid Build Coastguard Worker
1655*58b9f456SAndroid Build Coastguard Workerinline constexpr
1656*58b9f456SAndroid Build Coastguard Workerday operator+ (const days& __lhs, const day& __rhs) noexcept
1657*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
1658*58b9f456SAndroid Build Coastguard Worker
1659*58b9f456SAndroid Build Coastguard Workerinline constexpr
1660*58b9f456SAndroid Build Coastguard Workerday operator- (const day& __lhs, const days& __rhs) noexcept
1661*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
1662*58b9f456SAndroid Build Coastguard Worker
1663*58b9f456SAndroid Build Coastguard Workerinline constexpr
1664*58b9f456SAndroid Build Coastguard Workerdays operator-(const day& __lhs, const day& __rhs) noexcept
1665*58b9f456SAndroid Build Coastguard Worker{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
1666*58b9f456SAndroid Build Coastguard Worker              static_cast<int>(static_cast<unsigned>(__rhs))); }
1667*58b9f456SAndroid Build Coastguard Worker
1668*58b9f456SAndroid Build Coastguard Workerinline constexpr day& day::operator+=(const days& __dd) noexcept
1669*58b9f456SAndroid Build Coastguard Worker{ *this = *this + __dd; return *this; }
1670*58b9f456SAndroid Build Coastguard Worker
1671*58b9f456SAndroid Build Coastguard Workerinline constexpr day& day::operator-=(const days& __dd) noexcept
1672*58b9f456SAndroid Build Coastguard Worker{ *this = *this - __dd; return *this; }
1673*58b9f456SAndroid Build Coastguard Worker
1674*58b9f456SAndroid Build Coastguard Worker
1675*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS month {
1676*58b9f456SAndroid Build Coastguard Workerprivate:
1677*58b9f456SAndroid Build Coastguard Worker    unsigned char __m;
1678*58b9f456SAndroid Build Coastguard Workerpublic:
1679*58b9f456SAndroid Build Coastguard Worker    month() = default;
1680*58b9f456SAndroid Build Coastguard Worker    explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
1681*58b9f456SAndroid Build Coastguard Worker    inline constexpr month& operator++()    noexcept { ++__m; return *this; }
1682*58b9f456SAndroid Build Coastguard Worker    inline constexpr month  operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
1683*58b9f456SAndroid Build Coastguard Worker    inline constexpr month& operator--()    noexcept { --__m; return *this; }
1684*58b9f456SAndroid Build Coastguard Worker    inline constexpr month  operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
1685*58b9f456SAndroid Build Coastguard Worker           constexpr month& operator+=(const months& __m1) noexcept;
1686*58b9f456SAndroid Build Coastguard Worker           constexpr month& operator-=(const months& __m1) noexcept;
1687*58b9f456SAndroid Build Coastguard Worker    explicit inline constexpr operator unsigned() const noexcept { return __m; }
1688*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
1689*58b9f456SAndroid Build Coastguard Worker};
1690*58b9f456SAndroid Build Coastguard Worker
1691*58b9f456SAndroid Build Coastguard Worker
1692*58b9f456SAndroid Build Coastguard Workerinline constexpr
1693*58b9f456SAndroid Build Coastguard Workerbool operator==(const month& __lhs, const month& __rhs) noexcept
1694*58b9f456SAndroid Build Coastguard Worker{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
1695*58b9f456SAndroid Build Coastguard Worker
1696*58b9f456SAndroid Build Coastguard Workerinline constexpr
1697*58b9f456SAndroid Build Coastguard Workerbool operator!=(const month& __lhs, const month& __rhs) noexcept
1698*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
1699*58b9f456SAndroid Build Coastguard Worker
1700*58b9f456SAndroid Build Coastguard Workerinline constexpr
1701*58b9f456SAndroid Build Coastguard Workerbool operator< (const month& __lhs, const month& __rhs) noexcept
1702*58b9f456SAndroid Build Coastguard Worker{ return static_cast<unsigned>(__lhs)  < static_cast<unsigned>(__rhs); }
1703*58b9f456SAndroid Build Coastguard Worker
1704*58b9f456SAndroid Build Coastguard Workerinline constexpr
1705*58b9f456SAndroid Build Coastguard Workerbool operator> (const month& __lhs, const month& __rhs) noexcept
1706*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
1707*58b9f456SAndroid Build Coastguard Worker
1708*58b9f456SAndroid Build Coastguard Workerinline constexpr
1709*58b9f456SAndroid Build Coastguard Workerbool operator<=(const month& __lhs, const month& __rhs) noexcept
1710*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs); }
1711*58b9f456SAndroid Build Coastguard Worker
1712*58b9f456SAndroid Build Coastguard Workerinline constexpr
1713*58b9f456SAndroid Build Coastguard Workerbool operator>=(const month& __lhs, const month& __rhs) noexcept
1714*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
1715*58b9f456SAndroid Build Coastguard Worker
1716*58b9f456SAndroid Build Coastguard Workerinline constexpr
1717*58b9f456SAndroid Build Coastguard Workermonth operator+ (const month& __lhs, const months& __rhs) noexcept
1718*58b9f456SAndroid Build Coastguard Worker{
1719*58b9f456SAndroid Build Coastguard Worker    auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
1720*58b9f456SAndroid Build Coastguard Worker    auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
1721*58b9f456SAndroid Build Coastguard Worker    return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
1722*58b9f456SAndroid Build Coastguard Worker}
1723*58b9f456SAndroid Build Coastguard Worker
1724*58b9f456SAndroid Build Coastguard Workerinline constexpr
1725*58b9f456SAndroid Build Coastguard Workermonth operator+ (const months& __lhs, const month& __rhs) noexcept
1726*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
1727*58b9f456SAndroid Build Coastguard Worker
1728*58b9f456SAndroid Build Coastguard Workerinline constexpr
1729*58b9f456SAndroid Build Coastguard Workermonth operator- (const month& __lhs, const months& __rhs) noexcept
1730*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
1731*58b9f456SAndroid Build Coastguard Worker
1732*58b9f456SAndroid Build Coastguard Workerinline constexpr
1733*58b9f456SAndroid Build Coastguard Workermonths operator-(const month& __lhs, const month& __rhs) noexcept
1734*58b9f456SAndroid Build Coastguard Worker{
1735*58b9f456SAndroid Build Coastguard Worker    auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
1736*58b9f456SAndroid Build Coastguard Worker    return months(__dm <= 11 ? __dm : __dm + 12);
1737*58b9f456SAndroid Build Coastguard Worker}
1738*58b9f456SAndroid Build Coastguard Worker
1739*58b9f456SAndroid Build Coastguard Workerinline constexpr month& month::operator+=(const months& __dm) noexcept
1740*58b9f456SAndroid Build Coastguard Worker{ *this = *this + __dm; return *this; }
1741*58b9f456SAndroid Build Coastguard Worker
1742*58b9f456SAndroid Build Coastguard Workerinline constexpr month& month::operator-=(const months& __dm) noexcept
1743*58b9f456SAndroid Build Coastguard Worker{ *this = *this - __dm; return *this; }
1744*58b9f456SAndroid Build Coastguard Worker
1745*58b9f456SAndroid Build Coastguard Worker
1746*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS year {
1747*58b9f456SAndroid Build Coastguard Workerprivate:
1748*58b9f456SAndroid Build Coastguard Worker    short __y;
1749*58b9f456SAndroid Build Coastguard Workerpublic:
1750*58b9f456SAndroid Build Coastguard Worker    year() = default;
1751*58b9f456SAndroid Build Coastguard Worker    explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
1752*58b9f456SAndroid Build Coastguard Worker
1753*58b9f456SAndroid Build Coastguard Worker    inline constexpr year& operator++()    noexcept { ++__y; return *this; };
1754*58b9f456SAndroid Build Coastguard Worker    inline constexpr year  operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; };
1755*58b9f456SAndroid Build Coastguard Worker    inline constexpr year& operator--()    noexcept { --__y; return *this; };
1756*58b9f456SAndroid Build Coastguard Worker    inline constexpr year  operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; };
1757*58b9f456SAndroid Build Coastguard Worker           constexpr year& operator+=(const years& __dy) noexcept;
1758*58b9f456SAndroid Build Coastguard Worker           constexpr year& operator-=(const years& __dy) noexcept;
1759*58b9f456SAndroid Build Coastguard Worker    inline constexpr year operator+() const noexcept { return *this; }
1760*58b9f456SAndroid Build Coastguard Worker    inline constexpr year operator-() const noexcept { return year{-__y}; };
1761*58b9f456SAndroid Build Coastguard Worker
1762*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
1763*58b9f456SAndroid Build Coastguard Worker    explicit inline constexpr operator int() const noexcept { return __y; }
1764*58b9f456SAndroid Build Coastguard Worker           constexpr bool ok() const noexcept;
1765*58b9f456SAndroid Build Coastguard Worker    static inline constexpr year min() noexcept { return year{-32767}; }
1766*58b9f456SAndroid Build Coastguard Worker    static inline constexpr year max() noexcept { return year{ 32767}; }
1767*58b9f456SAndroid Build Coastguard Worker};
1768*58b9f456SAndroid Build Coastguard Worker
1769*58b9f456SAndroid Build Coastguard Worker
1770*58b9f456SAndroid Build Coastguard Workerinline constexpr
1771*58b9f456SAndroid Build Coastguard Workerbool operator==(const year& __lhs, const year& __rhs) noexcept
1772*58b9f456SAndroid Build Coastguard Worker{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
1773*58b9f456SAndroid Build Coastguard Worker
1774*58b9f456SAndroid Build Coastguard Workerinline constexpr
1775*58b9f456SAndroid Build Coastguard Workerbool operator!=(const year& __lhs, const year& __rhs) noexcept
1776*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
1777*58b9f456SAndroid Build Coastguard Worker
1778*58b9f456SAndroid Build Coastguard Workerinline constexpr
1779*58b9f456SAndroid Build Coastguard Workerbool operator< (const year& __lhs, const year& __rhs) noexcept
1780*58b9f456SAndroid Build Coastguard Worker{ return static_cast<int>(__lhs)  < static_cast<int>(__rhs); }
1781*58b9f456SAndroid Build Coastguard Worker
1782*58b9f456SAndroid Build Coastguard Workerinline constexpr
1783*58b9f456SAndroid Build Coastguard Workerbool operator> (const year& __lhs, const year& __rhs) noexcept
1784*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
1785*58b9f456SAndroid Build Coastguard Worker
1786*58b9f456SAndroid Build Coastguard Workerinline constexpr
1787*58b9f456SAndroid Build Coastguard Workerbool operator<=(const year& __lhs, const year& __rhs) noexcept
1788*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs); }
1789*58b9f456SAndroid Build Coastguard Worker
1790*58b9f456SAndroid Build Coastguard Workerinline constexpr
1791*58b9f456SAndroid Build Coastguard Workerbool operator>=(const year& __lhs, const year& __rhs) noexcept
1792*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
1793*58b9f456SAndroid Build Coastguard Worker
1794*58b9f456SAndroid Build Coastguard Workerinline constexpr
1795*58b9f456SAndroid Build Coastguard Workeryear operator+ (const year& __lhs, const years& __rhs) noexcept
1796*58b9f456SAndroid Build Coastguard Worker{ return year(static_cast<int>(__lhs) + __rhs.count()); }
1797*58b9f456SAndroid Build Coastguard Worker
1798*58b9f456SAndroid Build Coastguard Workerinline constexpr
1799*58b9f456SAndroid Build Coastguard Workeryear operator+ (const years& __lhs, const year& __rhs) noexcept
1800*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
1801*58b9f456SAndroid Build Coastguard Worker
1802*58b9f456SAndroid Build Coastguard Workerinline constexpr
1803*58b9f456SAndroid Build Coastguard Workeryear operator- (const year& __lhs, const years& __rhs) noexcept
1804*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
1805*58b9f456SAndroid Build Coastguard Worker
1806*58b9f456SAndroid Build Coastguard Workerinline constexpr
1807*58b9f456SAndroid Build Coastguard Workeryears operator-(const year& __lhs, const year& __rhs) noexcept
1808*58b9f456SAndroid Build Coastguard Worker{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
1809*58b9f456SAndroid Build Coastguard Worker
1810*58b9f456SAndroid Build Coastguard Worker
1811*58b9f456SAndroid Build Coastguard Workerinline constexpr year& year::operator+=(const years& __dy) noexcept
1812*58b9f456SAndroid Build Coastguard Worker{ *this = *this + __dy; return *this; }
1813*58b9f456SAndroid Build Coastguard Worker
1814*58b9f456SAndroid Build Coastguard Workerinline constexpr year& year::operator-=(const years& __dy) noexcept
1815*58b9f456SAndroid Build Coastguard Worker{ *this = *this - __dy; return *this; }
1816*58b9f456SAndroid Build Coastguard Worker
1817*58b9f456SAndroid Build Coastguard Workerinline constexpr bool year::ok() const noexcept
1818*58b9f456SAndroid Build Coastguard Worker{ return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); }
1819*58b9f456SAndroid Build Coastguard Worker
1820*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS weekday_indexed;
1821*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS weekday_last;
1822*58b9f456SAndroid Build Coastguard Worker
1823*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS weekday {
1824*58b9f456SAndroid Build Coastguard Workerprivate:
1825*58b9f456SAndroid Build Coastguard Worker    unsigned char __wd;
1826*58b9f456SAndroid Build Coastguard Workerpublic:
1827*58b9f456SAndroid Build Coastguard Worker  weekday() = default;
1828*58b9f456SAndroid Build Coastguard Worker  inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val)) {}
1829*58b9f456SAndroid Build Coastguard Worker  inline constexpr          weekday(const sys_days& __sysd) noexcept
1830*58b9f456SAndroid Build Coastguard Worker          : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
1831*58b9f456SAndroid Build Coastguard Worker  inline explicit constexpr weekday(const local_days& __locd) noexcept
1832*58b9f456SAndroid Build Coastguard Worker          : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
1833*58b9f456SAndroid Build Coastguard Worker
1834*58b9f456SAndroid Build Coastguard Worker  inline constexpr weekday& operator++()    noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
1835*58b9f456SAndroid Build Coastguard Worker  inline constexpr weekday  operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
1836*58b9f456SAndroid Build Coastguard Worker  inline constexpr weekday& operator--()    noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
1837*58b9f456SAndroid Build Coastguard Worker  inline constexpr weekday  operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
1838*58b9f456SAndroid Build Coastguard Worker         constexpr weekday& operator+=(const days& __dd) noexcept;
1839*58b9f456SAndroid Build Coastguard Worker         constexpr weekday& operator-=(const days& __dd) noexcept;
1840*58b9f456SAndroid Build Coastguard Worker  inline explicit constexpr operator unsigned() const noexcept { return __wd; }
1841*58b9f456SAndroid Build Coastguard Worker  inline constexpr bool ok() const noexcept { return __wd <= 6; }
1842*58b9f456SAndroid Build Coastguard Worker         constexpr weekday_indexed operator[](unsigned __index) const noexcept;
1843*58b9f456SAndroid Build Coastguard Worker         constexpr weekday_last    operator[](last_spec) const noexcept;
1844*58b9f456SAndroid Build Coastguard Worker
1845*58b9f456SAndroid Build Coastguard Worker  static constexpr unsigned char __weekday_from_days(int __days) noexcept;
1846*58b9f456SAndroid Build Coastguard Worker};
1847*58b9f456SAndroid Build Coastguard Worker
1848*58b9f456SAndroid Build Coastguard Worker
1849*58b9f456SAndroid Build Coastguard Worker// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
1850*58b9f456SAndroid Build Coastguard Workerinline constexpr
1851*58b9f456SAndroid Build Coastguard Workerunsigned char weekday::__weekday_from_days(int __days) noexcept
1852*58b9f456SAndroid Build Coastguard Worker{
1853*58b9f456SAndroid Build Coastguard Worker    return static_cast<unsigned char>(
1854*58b9f456SAndroid Build Coastguard Worker              static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
1855*58b9f456SAndroid Build Coastguard Worker           );
1856*58b9f456SAndroid Build Coastguard Worker}
1857*58b9f456SAndroid Build Coastguard Worker
1858*58b9f456SAndroid Build Coastguard Workerinline constexpr
1859*58b9f456SAndroid Build Coastguard Workerbool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
1860*58b9f456SAndroid Build Coastguard Worker{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
1861*58b9f456SAndroid Build Coastguard Worker
1862*58b9f456SAndroid Build Coastguard Workerinline constexpr
1863*58b9f456SAndroid Build Coastguard Workerbool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
1864*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
1865*58b9f456SAndroid Build Coastguard Worker
1866*58b9f456SAndroid Build Coastguard Workerinline constexpr
1867*58b9f456SAndroid Build Coastguard Workerbool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
1868*58b9f456SAndroid Build Coastguard Worker{ return static_cast<unsigned>(__lhs) <  static_cast<unsigned>(__rhs); }
1869*58b9f456SAndroid Build Coastguard Worker
1870*58b9f456SAndroid Build Coastguard Workerinline constexpr
1871*58b9f456SAndroid Build Coastguard Workerbool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
1872*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
1873*58b9f456SAndroid Build Coastguard Worker
1874*58b9f456SAndroid Build Coastguard Workerinline constexpr
1875*58b9f456SAndroid Build Coastguard Workerbool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
1876*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs);}
1877*58b9f456SAndroid Build Coastguard Worker
1878*58b9f456SAndroid Build Coastguard Workerinline constexpr
1879*58b9f456SAndroid Build Coastguard Workerbool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
1880*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
1881*58b9f456SAndroid Build Coastguard Worker
1882*58b9f456SAndroid Build Coastguard Workerconstexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
1883*58b9f456SAndroid Build Coastguard Worker{
1884*58b9f456SAndroid Build Coastguard Worker    auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + __rhs.count();
1885*58b9f456SAndroid Build Coastguard Worker    auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
1886*58b9f456SAndroid Build Coastguard Worker    return weekday{static_cast<unsigned>(__mu - __yr * 7)};
1887*58b9f456SAndroid Build Coastguard Worker}
1888*58b9f456SAndroid Build Coastguard Worker
1889*58b9f456SAndroid Build Coastguard Workerconstexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
1890*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
1891*58b9f456SAndroid Build Coastguard Worker
1892*58b9f456SAndroid Build Coastguard Workerconstexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
1893*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
1894*58b9f456SAndroid Build Coastguard Worker
1895*58b9f456SAndroid Build Coastguard Workerconstexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
1896*58b9f456SAndroid Build Coastguard Worker{
1897*58b9f456SAndroid Build Coastguard Worker    const int __wdu = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
1898*58b9f456SAndroid Build Coastguard Worker    const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
1899*58b9f456SAndroid Build Coastguard Worker    return days{__wdu - __wk * 7};
1900*58b9f456SAndroid Build Coastguard Worker}
1901*58b9f456SAndroid Build Coastguard Worker
1902*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday& weekday::operator+=(const days& __dd) noexcept
1903*58b9f456SAndroid Build Coastguard Worker{ *this = *this + __dd; return *this; }
1904*58b9f456SAndroid Build Coastguard Worker
1905*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
1906*58b9f456SAndroid Build Coastguard Worker{ *this = *this - __dd; return *this; }
1907*58b9f456SAndroid Build Coastguard Worker
1908*58b9f456SAndroid Build Coastguard Worker
1909*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS weekday_indexed {
1910*58b9f456SAndroid Build Coastguard Workerprivate:
1911*58b9f456SAndroid Build Coastguard Worker    _VSTD::chrono::weekday __wd;
1912*58b9f456SAndroid Build Coastguard Worker    unsigned char          __idx;
1913*58b9f456SAndroid Build Coastguard Workerpublic:
1914*58b9f456SAndroid Build Coastguard Worker    weekday_indexed() = default;
1915*58b9f456SAndroid Build Coastguard Worker    inline constexpr weekday_indexed(const _VSTD::chrono::weekday& __wdval, unsigned __idxval) noexcept
1916*58b9f456SAndroid Build Coastguard Worker        : __wd{__wdval}, __idx(__idxval) {}
1917*58b9f456SAndroid Build Coastguard Worker    inline constexpr _VSTD::chrono::weekday weekday() const noexcept { return __wd; }
1918*58b9f456SAndroid Build Coastguard Worker    inline constexpr unsigned                 index() const noexcept { return __idx; }
1919*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
1920*58b9f456SAndroid Build Coastguard Worker};
1921*58b9f456SAndroid Build Coastguard Worker
1922*58b9f456SAndroid Build Coastguard Workerinline constexpr
1923*58b9f456SAndroid Build Coastguard Workerbool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
1924*58b9f456SAndroid Build Coastguard Worker{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
1925*58b9f456SAndroid Build Coastguard Worker
1926*58b9f456SAndroid Build Coastguard Workerinline constexpr
1927*58b9f456SAndroid Build Coastguard Workerbool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
1928*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
1929*58b9f456SAndroid Build Coastguard Worker
1930*58b9f456SAndroid Build Coastguard Worker
1931*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS weekday_last {
1932*58b9f456SAndroid Build Coastguard Workerprivate:
1933*58b9f456SAndroid Build Coastguard Worker    _VSTD::chrono::weekday __wd;
1934*58b9f456SAndroid Build Coastguard Workerpublic:
1935*58b9f456SAndroid Build Coastguard Worker    explicit constexpr weekday_last(const _VSTD::chrono::weekday& __val) noexcept
1936*58b9f456SAndroid Build Coastguard Worker        : __wd{__val} {}
1937*58b9f456SAndroid Build Coastguard Worker    constexpr _VSTD::chrono::weekday weekday() const noexcept { return __wd; }
1938*58b9f456SAndroid Build Coastguard Worker    constexpr bool ok() const noexcept { return __wd.ok(); }
1939*58b9f456SAndroid Build Coastguard Worker};
1940*58b9f456SAndroid Build Coastguard Worker
1941*58b9f456SAndroid Build Coastguard Workerinline constexpr
1942*58b9f456SAndroid Build Coastguard Workerbool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
1943*58b9f456SAndroid Build Coastguard Worker{ return __lhs.weekday() == __rhs.weekday(); }
1944*58b9f456SAndroid Build Coastguard Worker
1945*58b9f456SAndroid Build Coastguard Workerinline constexpr
1946*58b9f456SAndroid Build Coastguard Workerbool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
1947*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
1948*58b9f456SAndroid Build Coastguard Worker
1949*58b9f456SAndroid Build Coastguard Workerinline constexpr
1950*58b9f456SAndroid Build Coastguard Workerweekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
1951*58b9f456SAndroid Build Coastguard Worker
1952*58b9f456SAndroid Build Coastguard Workerinline constexpr
1953*58b9f456SAndroid Build Coastguard Workerweekday_last    weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
1954*58b9f456SAndroid Build Coastguard Worker
1955*58b9f456SAndroid Build Coastguard Worker
1956*58b9f456SAndroid Build Coastguard Workerinline constexpr last_spec last{};
1957*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday   Sunday{0};
1958*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday   Monday{1};
1959*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday   Tuesday{2};
1960*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday   Wednesday{3};
1961*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday   Thursday{4};
1962*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday   Friday{5};
1963*58b9f456SAndroid Build Coastguard Workerinline constexpr weekday   Saturday{6};
1964*58b9f456SAndroid Build Coastguard Worker
1965*58b9f456SAndroid Build Coastguard Workerinline constexpr month January{1};
1966*58b9f456SAndroid Build Coastguard Workerinline constexpr month February{2};
1967*58b9f456SAndroid Build Coastguard Workerinline constexpr month March{3};
1968*58b9f456SAndroid Build Coastguard Workerinline constexpr month April{4};
1969*58b9f456SAndroid Build Coastguard Workerinline constexpr month May{5};
1970*58b9f456SAndroid Build Coastguard Workerinline constexpr month June{6};
1971*58b9f456SAndroid Build Coastguard Workerinline constexpr month July{7};
1972*58b9f456SAndroid Build Coastguard Workerinline constexpr month August{8};
1973*58b9f456SAndroid Build Coastguard Workerinline constexpr month September{9};
1974*58b9f456SAndroid Build Coastguard Workerinline constexpr month October{10};
1975*58b9f456SAndroid Build Coastguard Workerinline constexpr month November{11};
1976*58b9f456SAndroid Build Coastguard Workerinline constexpr month December{12};
1977*58b9f456SAndroid Build Coastguard Worker
1978*58b9f456SAndroid Build Coastguard Worker
1979*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS month_day {
1980*58b9f456SAndroid Build Coastguard Workerprivate:
1981*58b9f456SAndroid Build Coastguard Worker   chrono::month __m;
1982*58b9f456SAndroid Build Coastguard Worker   chrono::day   __d;
1983*58b9f456SAndroid Build Coastguard Workerpublic:
1984*58b9f456SAndroid Build Coastguard Worker    month_day() = default;
1985*58b9f456SAndroid Build Coastguard Worker    constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
1986*58b9f456SAndroid Build Coastguard Worker        : __m{__mval}, __d{__dval} {}
1987*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::month month() const noexcept { return __m; }
1988*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::day   day()   const noexcept { return __d; }
1989*58b9f456SAndroid Build Coastguard Worker    constexpr bool ok() const noexcept;
1990*58b9f456SAndroid Build Coastguard Worker};
1991*58b9f456SAndroid Build Coastguard Worker
1992*58b9f456SAndroid Build Coastguard Workerinline constexpr
1993*58b9f456SAndroid Build Coastguard Workerbool month_day::ok() const noexcept
1994*58b9f456SAndroid Build Coastguard Worker{
1995*58b9f456SAndroid Build Coastguard Worker    if (!__m.ok()) return false;
1996*58b9f456SAndroid Build Coastguard Worker    const unsigned __dval = static_cast<unsigned>(__d);
1997*58b9f456SAndroid Build Coastguard Worker    if (__dval < 1 || __dval > 31) return false;
1998*58b9f456SAndroid Build Coastguard Worker    if (__dval <= 29) return true;
1999*58b9f456SAndroid Build Coastguard Worker//  Now we've got either 30 or 31
2000*58b9f456SAndroid Build Coastguard Worker    const unsigned __mval = static_cast<unsigned>(__m);
2001*58b9f456SAndroid Build Coastguard Worker    if (__mval == 2) return false;
2002*58b9f456SAndroid Build Coastguard Worker    if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
2003*58b9f456SAndroid Build Coastguard Worker        return __dval == 30;
2004*58b9f456SAndroid Build Coastguard Worker    return true;
2005*58b9f456SAndroid Build Coastguard Worker}
2006*58b9f456SAndroid Build Coastguard Worker
2007*58b9f456SAndroid Build Coastguard Workerinline constexpr
2008*58b9f456SAndroid Build Coastguard Workerbool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
2009*58b9f456SAndroid Build Coastguard Worker{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
2010*58b9f456SAndroid Build Coastguard Worker
2011*58b9f456SAndroid Build Coastguard Workerinline constexpr
2012*58b9f456SAndroid Build Coastguard Workerbool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
2013*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2014*58b9f456SAndroid Build Coastguard Worker
2015*58b9f456SAndroid Build Coastguard Workerinline constexpr
2016*58b9f456SAndroid Build Coastguard Workermonth_day operator/(const month& __lhs, const day& __rhs) noexcept
2017*58b9f456SAndroid Build Coastguard Worker{ return month_day{__lhs, __rhs}; }
2018*58b9f456SAndroid Build Coastguard Worker
2019*58b9f456SAndroid Build Coastguard Workerconstexpr
2020*58b9f456SAndroid Build Coastguard Workermonth_day operator/(const day& __lhs, const month& __rhs) noexcept
2021*58b9f456SAndroid Build Coastguard Worker{ return __rhs / __lhs; }
2022*58b9f456SAndroid Build Coastguard Worker
2023*58b9f456SAndroid Build Coastguard Workerinline constexpr
2024*58b9f456SAndroid Build Coastguard Workermonth_day operator/(const month& __lhs, int __rhs) noexcept
2025*58b9f456SAndroid Build Coastguard Worker{ return __lhs / day(__rhs); }
2026*58b9f456SAndroid Build Coastguard Worker
2027*58b9f456SAndroid Build Coastguard Workerconstexpr
2028*58b9f456SAndroid Build Coastguard Workermonth_day operator/(int __lhs, const day& __rhs) noexcept
2029*58b9f456SAndroid Build Coastguard Worker{ return month(__lhs) / __rhs; }
2030*58b9f456SAndroid Build Coastguard Worker
2031*58b9f456SAndroid Build Coastguard Workerconstexpr
2032*58b9f456SAndroid Build Coastguard Workermonth_day operator/(const day& __lhs, int __rhs) noexcept
2033*58b9f456SAndroid Build Coastguard Worker{ return month(__rhs) / __lhs; }
2034*58b9f456SAndroid Build Coastguard Worker
2035*58b9f456SAndroid Build Coastguard Worker
2036*58b9f456SAndroid Build Coastguard Workerinline constexpr
2037*58b9f456SAndroid Build Coastguard Workerbool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
2038*58b9f456SAndroid Build Coastguard Worker{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
2039*58b9f456SAndroid Build Coastguard Worker
2040*58b9f456SAndroid Build Coastguard Workerinline constexpr
2041*58b9f456SAndroid Build Coastguard Workerbool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
2042*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
2043*58b9f456SAndroid Build Coastguard Worker
2044*58b9f456SAndroid Build Coastguard Workerinline constexpr
2045*58b9f456SAndroid Build Coastguard Workerbool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
2046*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs);}
2047*58b9f456SAndroid Build Coastguard Worker
2048*58b9f456SAndroid Build Coastguard Workerinline constexpr
2049*58b9f456SAndroid Build Coastguard Workerbool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
2050*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
2051*58b9f456SAndroid Build Coastguard Worker
2052*58b9f456SAndroid Build Coastguard Worker
2053*58b9f456SAndroid Build Coastguard Worker
2054*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS month_day_last {
2055*58b9f456SAndroid Build Coastguard Workerprivate:
2056*58b9f456SAndroid Build Coastguard Worker    chrono::month __m;
2057*58b9f456SAndroid Build Coastguard Workerpublic:
2058*58b9f456SAndroid Build Coastguard Worker    explicit constexpr month_day_last(const chrono::month& __val) noexcept
2059*58b9f456SAndroid Build Coastguard Worker        : __m{__val} {}
2060*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::month month() const noexcept { return __m; }
2061*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool ok() const noexcept { return __m.ok(); }
2062*58b9f456SAndroid Build Coastguard Worker};
2063*58b9f456SAndroid Build Coastguard Worker
2064*58b9f456SAndroid Build Coastguard Workerinline constexpr
2065*58b9f456SAndroid Build Coastguard Workerbool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
2066*58b9f456SAndroid Build Coastguard Worker{ return __lhs.month() == __rhs.month(); }
2067*58b9f456SAndroid Build Coastguard Worker
2068*58b9f456SAndroid Build Coastguard Workerinline constexpr
2069*58b9f456SAndroid Build Coastguard Workerbool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
2070*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2071*58b9f456SAndroid Build Coastguard Worker
2072*58b9f456SAndroid Build Coastguard Workerinline constexpr
2073*58b9f456SAndroid Build Coastguard Workerbool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
2074*58b9f456SAndroid Build Coastguard Worker{ return __lhs.month() < __rhs.month(); }
2075*58b9f456SAndroid Build Coastguard Worker
2076*58b9f456SAndroid Build Coastguard Workerinline constexpr
2077*58b9f456SAndroid Build Coastguard Workerbool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
2078*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
2079*58b9f456SAndroid Build Coastguard Worker
2080*58b9f456SAndroid Build Coastguard Workerinline constexpr
2081*58b9f456SAndroid Build Coastguard Workerbool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
2082*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs);}
2083*58b9f456SAndroid Build Coastguard Worker
2084*58b9f456SAndroid Build Coastguard Workerinline constexpr
2085*58b9f456SAndroid Build Coastguard Workerbool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
2086*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
2087*58b9f456SAndroid Build Coastguard Worker
2088*58b9f456SAndroid Build Coastguard Workerinline constexpr
2089*58b9f456SAndroid Build Coastguard Workermonth_day_last operator/(const month& __lhs, last_spec) noexcept
2090*58b9f456SAndroid Build Coastguard Worker{ return month_day_last{__lhs}; }
2091*58b9f456SAndroid Build Coastguard Worker
2092*58b9f456SAndroid Build Coastguard Workerinline constexpr
2093*58b9f456SAndroid Build Coastguard Workermonth_day_last operator/(last_spec, const month& __rhs) noexcept
2094*58b9f456SAndroid Build Coastguard Worker{ return month_day_last{__rhs}; }
2095*58b9f456SAndroid Build Coastguard Worker
2096*58b9f456SAndroid Build Coastguard Workerinline constexpr
2097*58b9f456SAndroid Build Coastguard Workermonth_day_last operator/(int __lhs, last_spec) noexcept
2098*58b9f456SAndroid Build Coastguard Worker{ return month_day_last{month(__lhs)}; }
2099*58b9f456SAndroid Build Coastguard Worker
2100*58b9f456SAndroid Build Coastguard Workerinline constexpr
2101*58b9f456SAndroid Build Coastguard Workermonth_day_last operator/(last_spec, int __rhs) noexcept
2102*58b9f456SAndroid Build Coastguard Worker{ return month_day_last{month(__rhs)}; }
2103*58b9f456SAndroid Build Coastguard Worker
2104*58b9f456SAndroid Build Coastguard Worker
2105*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS month_weekday {
2106*58b9f456SAndroid Build Coastguard Workerprivate:
2107*58b9f456SAndroid Build Coastguard Worker    chrono::month __m;
2108*58b9f456SAndroid Build Coastguard Worker    chrono::weekday_indexed __wdi;
2109*58b9f456SAndroid Build Coastguard Workerpublic:
2110*58b9f456SAndroid Build Coastguard Worker    month_weekday() = default;
2111*58b9f456SAndroid Build Coastguard Worker    constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
2112*58b9f456SAndroid Build Coastguard Worker        : __m{__mval}, __wdi{__wdival} {}
2113*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::month                     month() const noexcept { return __m; }
2114*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
2115*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool                                 ok() const noexcept { return __m.ok() && __wdi.ok(); }
2116*58b9f456SAndroid Build Coastguard Worker};
2117*58b9f456SAndroid Build Coastguard Worker
2118*58b9f456SAndroid Build Coastguard Workerinline constexpr
2119*58b9f456SAndroid Build Coastguard Workerbool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
2120*58b9f456SAndroid Build Coastguard Worker{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
2121*58b9f456SAndroid Build Coastguard Worker
2122*58b9f456SAndroid Build Coastguard Workerinline constexpr
2123*58b9f456SAndroid Build Coastguard Workerbool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
2124*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2125*58b9f456SAndroid Build Coastguard Worker
2126*58b9f456SAndroid Build Coastguard Workerinline constexpr
2127*58b9f456SAndroid Build Coastguard Workermonth_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
2128*58b9f456SAndroid Build Coastguard Worker{ return month_weekday{__lhs, __rhs}; }
2129*58b9f456SAndroid Build Coastguard Worker
2130*58b9f456SAndroid Build Coastguard Workerinline constexpr
2131*58b9f456SAndroid Build Coastguard Workermonth_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
2132*58b9f456SAndroid Build Coastguard Worker{ return month_weekday{month(__lhs), __rhs}; }
2133*58b9f456SAndroid Build Coastguard Worker
2134*58b9f456SAndroid Build Coastguard Workerinline constexpr
2135*58b9f456SAndroid Build Coastguard Workermonth_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
2136*58b9f456SAndroid Build Coastguard Worker{ return month_weekday{__rhs, __lhs}; }
2137*58b9f456SAndroid Build Coastguard Worker
2138*58b9f456SAndroid Build Coastguard Workerinline constexpr
2139*58b9f456SAndroid Build Coastguard Workermonth_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
2140*58b9f456SAndroid Build Coastguard Worker{ return month_weekday{month(__rhs), __lhs}; }
2141*58b9f456SAndroid Build Coastguard Worker
2142*58b9f456SAndroid Build Coastguard Worker
2143*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS month_weekday_last {
2144*58b9f456SAndroid Build Coastguard Worker    chrono::month        __m;
2145*58b9f456SAndroid Build Coastguard Worker    chrono::weekday_last __wdl;
2146*58b9f456SAndroid Build Coastguard Worker  public:
2147*58b9f456SAndroid Build Coastguard Worker    constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
2148*58b9f456SAndroid Build Coastguard Worker        : __m{__mval}, __wdl{__wdlval} {}
2149*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::month               month() const noexcept { return __m; }
2150*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
2151*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool                           ok() const noexcept { return __m.ok() && __wdl.ok(); }
2152*58b9f456SAndroid Build Coastguard Worker};
2153*58b9f456SAndroid Build Coastguard Worker
2154*58b9f456SAndroid Build Coastguard Workerinline constexpr
2155*58b9f456SAndroid Build Coastguard Workerbool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
2156*58b9f456SAndroid Build Coastguard Worker{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
2157*58b9f456SAndroid Build Coastguard Worker
2158*58b9f456SAndroid Build Coastguard Workerinline constexpr
2159*58b9f456SAndroid Build Coastguard Workerbool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
2160*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2161*58b9f456SAndroid Build Coastguard Worker
2162*58b9f456SAndroid Build Coastguard Worker
2163*58b9f456SAndroid Build Coastguard Workerinline constexpr
2164*58b9f456SAndroid Build Coastguard Workermonth_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
2165*58b9f456SAndroid Build Coastguard Worker{ return month_weekday_last{__lhs, __rhs}; }
2166*58b9f456SAndroid Build Coastguard Worker
2167*58b9f456SAndroid Build Coastguard Workerinline constexpr
2168*58b9f456SAndroid Build Coastguard Workermonth_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
2169*58b9f456SAndroid Build Coastguard Worker{ return month_weekday_last{month(__lhs), __rhs}; }
2170*58b9f456SAndroid Build Coastguard Worker
2171*58b9f456SAndroid Build Coastguard Workerinline constexpr
2172*58b9f456SAndroid Build Coastguard Workermonth_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
2173*58b9f456SAndroid Build Coastguard Worker{ return month_weekday_last{__rhs, __lhs}; }
2174*58b9f456SAndroid Build Coastguard Worker
2175*58b9f456SAndroid Build Coastguard Workerinline constexpr
2176*58b9f456SAndroid Build Coastguard Workermonth_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
2177*58b9f456SAndroid Build Coastguard Worker{ return month_weekday_last{month(__rhs), __lhs}; }
2178*58b9f456SAndroid Build Coastguard Worker
2179*58b9f456SAndroid Build Coastguard Worker
2180*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS year_month {
2181*58b9f456SAndroid Build Coastguard Worker    chrono::year  __y;
2182*58b9f456SAndroid Build Coastguard Worker    chrono::month __m;
2183*58b9f456SAndroid Build Coastguard Workerpublic:
2184*58b9f456SAndroid Build Coastguard Worker    year_month() = default;
2185*58b9f456SAndroid Build Coastguard Worker    constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
2186*58b9f456SAndroid Build Coastguard Worker        : __y{__yval}, __m{__mval} {}
2187*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::year  year()  const noexcept { return __y; }
2188*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::month month() const noexcept { return __m; }
2189*58b9f456SAndroid Build Coastguard Worker    inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
2190*58b9f456SAndroid Build Coastguard Worker    inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
2191*58b9f456SAndroid Build Coastguard Worker    inline constexpr year_month& operator+=(const years& __dy)  noexcept { this->__y += __dy; return *this; }
2192*58b9f456SAndroid Build Coastguard Worker    inline constexpr year_month& operator-=(const years& __dy)  noexcept { this->__y -= __dy; return *this; }
2193*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
2194*58b9f456SAndroid Build Coastguard Worker};
2195*58b9f456SAndroid Build Coastguard Worker
2196*58b9f456SAndroid Build Coastguard Workerinline constexpr
2197*58b9f456SAndroid Build Coastguard Workeryear_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
2198*58b9f456SAndroid Build Coastguard Worker
2199*58b9f456SAndroid Build Coastguard Workerinline constexpr
2200*58b9f456SAndroid Build Coastguard Workeryear_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
2201*58b9f456SAndroid Build Coastguard Worker
2202*58b9f456SAndroid Build Coastguard Workerinline constexpr
2203*58b9f456SAndroid Build Coastguard Workerbool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
2204*58b9f456SAndroid Build Coastguard Worker{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
2205*58b9f456SAndroid Build Coastguard Worker
2206*58b9f456SAndroid Build Coastguard Workerinline constexpr
2207*58b9f456SAndroid Build Coastguard Workerbool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
2208*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2209*58b9f456SAndroid Build Coastguard Worker
2210*58b9f456SAndroid Build Coastguard Workerinline constexpr
2211*58b9f456SAndroid Build Coastguard Workerbool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
2212*58b9f456SAndroid Build Coastguard Worker{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
2213*58b9f456SAndroid Build Coastguard Worker
2214*58b9f456SAndroid Build Coastguard Workerinline constexpr
2215*58b9f456SAndroid Build Coastguard Workerbool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
2216*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
2217*58b9f456SAndroid Build Coastguard Worker
2218*58b9f456SAndroid Build Coastguard Workerinline constexpr
2219*58b9f456SAndroid Build Coastguard Workerbool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
2220*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs);}
2221*58b9f456SAndroid Build Coastguard Worker
2222*58b9f456SAndroid Build Coastguard Workerinline constexpr
2223*58b9f456SAndroid Build Coastguard Workerbool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
2224*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
2225*58b9f456SAndroid Build Coastguard Worker
2226*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
2227*58b9f456SAndroid Build Coastguard Worker{
2228*58b9f456SAndroid Build Coastguard Worker    int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
2229*58b9f456SAndroid Build Coastguard Worker    const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
2230*58b9f456SAndroid Build Coastguard Worker    __dmi = __dmi - __dy * 12 + 1;
2231*58b9f456SAndroid Build Coastguard Worker    return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
2232*58b9f456SAndroid Build Coastguard Worker}
2233*58b9f456SAndroid Build Coastguard Worker
2234*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
2235*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2236*58b9f456SAndroid Build Coastguard Worker
2237*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
2238*58b9f456SAndroid Build Coastguard Worker{ return (__lhs.year() + __rhs) / __lhs.month(); }
2239*58b9f456SAndroid Build Coastguard Worker
2240*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
2241*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2242*58b9f456SAndroid Build Coastguard Worker
2243*58b9f456SAndroid Build Coastguard Workerconstexpr months     operator-(const year_month& __lhs, const year_month& __rhs) noexcept
2244*58b9f456SAndroid Build Coastguard Worker{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
2245*58b9f456SAndroid Build Coastguard Worker
2246*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
2247*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
2248*58b9f456SAndroid Build Coastguard Worker
2249*58b9f456SAndroid Build Coastguard Workerconstexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
2250*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
2251*58b9f456SAndroid Build Coastguard Worker
2252*58b9f456SAndroid Build Coastguard Workerclass year_month_day_last;
2253*58b9f456SAndroid Build Coastguard Worker
2254*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS year_month_day {
2255*58b9f456SAndroid Build Coastguard Workerprivate:
2256*58b9f456SAndroid Build Coastguard Worker    chrono::year  __y;
2257*58b9f456SAndroid Build Coastguard Worker    chrono::month __m;
2258*58b9f456SAndroid Build Coastguard Worker    chrono::day   __d;
2259*58b9f456SAndroid Build Coastguard Workerpublic:
2260*58b9f456SAndroid Build Coastguard Worker     year_month_day() = default;
2261*58b9f456SAndroid Build Coastguard Worker     inline constexpr year_month_day(
2262*58b9f456SAndroid Build Coastguard Worker            const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
2263*58b9f456SAndroid Build Coastguard Worker            : __y{__yval}, __m{__mval}, __d{__dval} {}
2264*58b9f456SAndroid Build Coastguard Worker            constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
2265*58b9f456SAndroid Build Coastguard Worker     inline constexpr year_month_day(const sys_days& __sysd) noexcept
2266*58b9f456SAndroid Build Coastguard Worker            : year_month_day(__from_days(__sysd.time_since_epoch())) {}
2267*58b9f456SAndroid Build Coastguard Worker     inline explicit constexpr year_month_day(const local_days& __locd) noexcept
2268*58b9f456SAndroid Build Coastguard Worker            : year_month_day(__from_days(__locd.time_since_epoch())) {}
2269*58b9f456SAndroid Build Coastguard Worker
2270*58b9f456SAndroid Build Coastguard Worker            constexpr year_month_day& operator+=(const months& __dm) noexcept;
2271*58b9f456SAndroid Build Coastguard Worker            constexpr year_month_day& operator-=(const months& __dm) noexcept;
2272*58b9f456SAndroid Build Coastguard Worker            constexpr year_month_day& operator+=(const years& __dy)  noexcept;
2273*58b9f456SAndroid Build Coastguard Worker            constexpr year_month_day& operator-=(const years& __dy)  noexcept;
2274*58b9f456SAndroid Build Coastguard Worker
2275*58b9f456SAndroid Build Coastguard Worker     inline constexpr chrono::year   year() const noexcept { return __y; }
2276*58b9f456SAndroid Build Coastguard Worker     inline constexpr chrono::month month() const noexcept { return __m; }
2277*58b9f456SAndroid Build Coastguard Worker     inline constexpr chrono::day     day() const noexcept { return __d; }
2278*58b9f456SAndroid Build Coastguard Worker     inline constexpr operator   sys_days() const noexcept          { return   sys_days{__to_days()}; }
2279*58b9f456SAndroid Build Coastguard Worker     inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
2280*58b9f456SAndroid Build Coastguard Worker
2281*58b9f456SAndroid Build Coastguard Worker            constexpr bool             ok() const noexcept;
2282*58b9f456SAndroid Build Coastguard Worker
2283*58b9f456SAndroid Build Coastguard Worker     static constexpr year_month_day __from_days(days __d) noexcept;
2284*58b9f456SAndroid Build Coastguard Worker     constexpr days __to_days() const noexcept;
2285*58b9f456SAndroid Build Coastguard Worker};
2286*58b9f456SAndroid Build Coastguard Worker
2287*58b9f456SAndroid Build Coastguard Worker
2288*58b9f456SAndroid Build Coastguard Worker// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
2289*58b9f456SAndroid Build Coastguard Workerinline constexpr
2290*58b9f456SAndroid Build Coastguard Workeryear_month_day
2291*58b9f456SAndroid Build Coastguard Workeryear_month_day::__from_days(days __d) noexcept
2292*58b9f456SAndroid Build Coastguard Worker{
2293*58b9f456SAndroid Build Coastguard Worker    static_assert(std::numeric_limits<unsigned>::digits >= 18, "");
2294*58b9f456SAndroid Build Coastguard Worker    static_assert(std::numeric_limits<int>::digits >= 20     , "");
2295*58b9f456SAndroid Build Coastguard Worker    const int      __z = __d.count() + 719468;
2296*58b9f456SAndroid Build Coastguard Worker    const int      __era = (__z >= 0 ? __z : __z - 146096) / 146097;
2297*58b9f456SAndroid Build Coastguard Worker    const unsigned __doe = static_cast<unsigned>(__z - __era * 146097);              // [0, 146096]
2298*58b9f456SAndroid Build Coastguard Worker    const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365;  // [0, 399]
2299*58b9f456SAndroid Build Coastguard Worker    const int      __yr = static_cast<int>(__yoe) + __era * 400;
2300*58b9f456SAndroid Build Coastguard Worker    const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100);              // [0, 365]
2301*58b9f456SAndroid Build Coastguard Worker    const unsigned __mp = (5 * __doy + 2)/153;                                       // [0, 11]
2302*58b9f456SAndroid Build Coastguard Worker    const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1;                            // [1, 31]
2303*58b9f456SAndroid Build Coastguard Worker    const unsigned __mth = __mp + (__mp < 10 ? 3 : -9);                              // [1, 12]
2304*58b9f456SAndroid Build Coastguard Worker    return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
2305*58b9f456SAndroid Build Coastguard Worker}
2306*58b9f456SAndroid Build Coastguard Worker
2307*58b9f456SAndroid Build Coastguard Worker// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
2308*58b9f456SAndroid Build Coastguard Workerinline constexpr days year_month_day::__to_days() const noexcept
2309*58b9f456SAndroid Build Coastguard Worker{
2310*58b9f456SAndroid Build Coastguard Worker    static_assert(std::numeric_limits<unsigned>::digits >= 18, "");
2311*58b9f456SAndroid Build Coastguard Worker    static_assert(std::numeric_limits<int>::digits >= 20     , "");
2312*58b9f456SAndroid Build Coastguard Worker
2313*58b9f456SAndroid Build Coastguard Worker    const int      __yr  = static_cast<int>(__y) - (__m <= February);
2314*58b9f456SAndroid Build Coastguard Worker    const unsigned __mth = static_cast<unsigned>(__m);
2315*58b9f456SAndroid Build Coastguard Worker    const unsigned __dy  = static_cast<unsigned>(__d);
2316*58b9f456SAndroid Build Coastguard Worker
2317*58b9f456SAndroid Build Coastguard Worker    const int      __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
2318*58b9f456SAndroid Build Coastguard Worker    const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400);                // [0, 399]
2319*58b9f456SAndroid Build Coastguard Worker    const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1;  // [0, 365]
2320*58b9f456SAndroid Build Coastguard Worker    const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy;                // [0, 146096]
2321*58b9f456SAndroid Build Coastguard Worker    return days{__era * 146097 + static_cast<int>(__doe) - 719468};
2322*58b9f456SAndroid Build Coastguard Worker}
2323*58b9f456SAndroid Build Coastguard Worker
2324*58b9f456SAndroid Build Coastguard Workerinline constexpr
2325*58b9f456SAndroid Build Coastguard Workerbool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
2326*58b9f456SAndroid Build Coastguard Worker{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
2327*58b9f456SAndroid Build Coastguard Worker
2328*58b9f456SAndroid Build Coastguard Workerinline constexpr
2329*58b9f456SAndroid Build Coastguard Workerbool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
2330*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2331*58b9f456SAndroid Build Coastguard Worker
2332*58b9f456SAndroid Build Coastguard Workerinline constexpr
2333*58b9f456SAndroid Build Coastguard Workerbool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
2334*58b9f456SAndroid Build Coastguard Worker{
2335*58b9f456SAndroid Build Coastguard Worker    if (__lhs.year() < __rhs.year()) return true;
2336*58b9f456SAndroid Build Coastguard Worker    if (__lhs.year() > __rhs.year()) return false;
2337*58b9f456SAndroid Build Coastguard Worker    if (__lhs.month() < __rhs.month()) return true;
2338*58b9f456SAndroid Build Coastguard Worker    if (__lhs.month() > __rhs.month()) return false;
2339*58b9f456SAndroid Build Coastguard Worker    return __lhs.day() < __rhs.day();
2340*58b9f456SAndroid Build Coastguard Worker}
2341*58b9f456SAndroid Build Coastguard Worker
2342*58b9f456SAndroid Build Coastguard Workerinline constexpr
2343*58b9f456SAndroid Build Coastguard Workerbool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
2344*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
2345*58b9f456SAndroid Build Coastguard Worker
2346*58b9f456SAndroid Build Coastguard Workerinline constexpr
2347*58b9f456SAndroid Build Coastguard Workerbool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
2348*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs);}
2349*58b9f456SAndroid Build Coastguard Worker
2350*58b9f456SAndroid Build Coastguard Workerinline constexpr
2351*58b9f456SAndroid Build Coastguard Workerbool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
2352*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
2353*58b9f456SAndroid Build Coastguard Worker
2354*58b9f456SAndroid Build Coastguard Workerinline constexpr
2355*58b9f456SAndroid Build Coastguard Workeryear_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
2356*58b9f456SAndroid Build Coastguard Worker{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
2357*58b9f456SAndroid Build Coastguard Worker
2358*58b9f456SAndroid Build Coastguard Workerinline constexpr
2359*58b9f456SAndroid Build Coastguard Workeryear_month_day operator/(const year_month& __lhs, int __rhs) noexcept
2360*58b9f456SAndroid Build Coastguard Worker{ return __lhs / day(__rhs); }
2361*58b9f456SAndroid Build Coastguard Worker
2362*58b9f456SAndroid Build Coastguard Workerinline constexpr
2363*58b9f456SAndroid Build Coastguard Workeryear_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
2364*58b9f456SAndroid Build Coastguard Worker{ return __lhs / __rhs.month() / __rhs.day(); }
2365*58b9f456SAndroid Build Coastguard Worker
2366*58b9f456SAndroid Build Coastguard Workerinline constexpr
2367*58b9f456SAndroid Build Coastguard Workeryear_month_day operator/(int __lhs, const month_day& __rhs) noexcept
2368*58b9f456SAndroid Build Coastguard Worker{ return year(__lhs) / __rhs; }
2369*58b9f456SAndroid Build Coastguard Worker
2370*58b9f456SAndroid Build Coastguard Workerinline constexpr
2371*58b9f456SAndroid Build Coastguard Workeryear_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
2372*58b9f456SAndroid Build Coastguard Worker{ return __rhs / __lhs; }
2373*58b9f456SAndroid Build Coastguard Worker
2374*58b9f456SAndroid Build Coastguard Workerinline constexpr
2375*58b9f456SAndroid Build Coastguard Workeryear_month_day operator/(const month_day& __lhs, int __rhs) noexcept
2376*58b9f456SAndroid Build Coastguard Worker{ return year(__rhs) / __lhs; }
2377*58b9f456SAndroid Build Coastguard Worker
2378*58b9f456SAndroid Build Coastguard Worker
2379*58b9f456SAndroid Build Coastguard Workerinline constexpr
2380*58b9f456SAndroid Build Coastguard Workeryear_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
2381*58b9f456SAndroid Build Coastguard Worker{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
2382*58b9f456SAndroid Build Coastguard Worker
2383*58b9f456SAndroid Build Coastguard Workerinline constexpr
2384*58b9f456SAndroid Build Coastguard Workeryear_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
2385*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2386*58b9f456SAndroid Build Coastguard Worker
2387*58b9f456SAndroid Build Coastguard Workerinline constexpr
2388*58b9f456SAndroid Build Coastguard Workeryear_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
2389*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
2390*58b9f456SAndroid Build Coastguard Worker
2391*58b9f456SAndroid Build Coastguard Workerinline constexpr
2392*58b9f456SAndroid Build Coastguard Workeryear_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
2393*58b9f456SAndroid Build Coastguard Worker{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
2394*58b9f456SAndroid Build Coastguard Worker
2395*58b9f456SAndroid Build Coastguard Workerinline constexpr
2396*58b9f456SAndroid Build Coastguard Workeryear_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
2397*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2398*58b9f456SAndroid Build Coastguard Worker
2399*58b9f456SAndroid Build Coastguard Workerinline constexpr
2400*58b9f456SAndroid Build Coastguard Workeryear_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
2401*58b9f456SAndroid Build Coastguard Worker{ return __lhs + -__rhs; }
2402*58b9f456SAndroid Build Coastguard Worker
2403*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
2404*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
2405*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day& year_month_day::operator+=(const years& __dy)  noexcept { *this = *this + __dy; return *this; }
2406*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day& year_month_day::operator-=(const years& __dy)  noexcept { *this = *this - __dy; return *this; }
2407*58b9f456SAndroid Build Coastguard Worker
2408*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS year_month_day_last {
2409*58b9f456SAndroid Build Coastguard Workerprivate:
2410*58b9f456SAndroid Build Coastguard Worker    chrono::year           __y;
2411*58b9f456SAndroid Build Coastguard Worker    chrono::month_day_last __mdl;
2412*58b9f456SAndroid Build Coastguard Workerpublic:
2413*58b9f456SAndroid Build Coastguard Worker     constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
2414*58b9f456SAndroid Build Coastguard Worker        : __y{__yval}, __mdl{__mdlval} {}
2415*58b9f456SAndroid Build Coastguard Worker
2416*58b9f456SAndroid Build Coastguard Worker     constexpr year_month_day_last& operator+=(const months& __m) noexcept;
2417*58b9f456SAndroid Build Coastguard Worker     constexpr year_month_day_last& operator-=(const months& __m) noexcept;
2418*58b9f456SAndroid Build Coastguard Worker     constexpr year_month_day_last& operator+=(const years& __y)  noexcept;
2419*58b9f456SAndroid Build Coastguard Worker     constexpr year_month_day_last& operator-=(const years& __y)  noexcept;
2420*58b9f456SAndroid Build Coastguard Worker
2421*58b9f456SAndroid Build Coastguard Worker     inline constexpr chrono::year                     year() const noexcept { return __y; }
2422*58b9f456SAndroid Build Coastguard Worker     inline constexpr chrono::month                   month() const noexcept { return __mdl.month(); }
2423*58b9f456SAndroid Build Coastguard Worker     inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
2424*58b9f456SAndroid Build Coastguard Worker            constexpr chrono::day                       day() const noexcept;
2425*58b9f456SAndroid Build Coastguard Worker     inline constexpr operator                     sys_days() const noexcept { return   sys_days{year()/month()/day()}; }
2426*58b9f456SAndroid Build Coastguard Worker     inline explicit constexpr operator          local_days() const noexcept { return local_days{year()/month()/day()}; }
2427*58b9f456SAndroid Build Coastguard Worker     inline constexpr bool                               ok() const noexcept { return __y.ok() && __mdl.ok(); }
2428*58b9f456SAndroid Build Coastguard Worker};
2429*58b9f456SAndroid Build Coastguard Worker
2430*58b9f456SAndroid Build Coastguard Workerinline constexpr
2431*58b9f456SAndroid Build Coastguard Workerchrono::day year_month_day_last::day() const noexcept
2432*58b9f456SAndroid Build Coastguard Worker{
2433*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::day __d[] =
2434*58b9f456SAndroid Build Coastguard Worker    {
2435*58b9f456SAndroid Build Coastguard Worker        chrono::day(31), chrono::day(28), chrono::day(31),
2436*58b9f456SAndroid Build Coastguard Worker        chrono::day(30), chrono::day(31), chrono::day(30),
2437*58b9f456SAndroid Build Coastguard Worker        chrono::day(31), chrono::day(31), chrono::day(30),
2438*58b9f456SAndroid Build Coastguard Worker        chrono::day(31), chrono::day(30), chrono::day(31)
2439*58b9f456SAndroid Build Coastguard Worker    };
2440*58b9f456SAndroid Build Coastguard Worker    return month() != February || !__y.is_leap() ?
2441*58b9f456SAndroid Build Coastguard Worker        __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
2442*58b9f456SAndroid Build Coastguard Worker}
2443*58b9f456SAndroid Build Coastguard Worker
2444*58b9f456SAndroid Build Coastguard Workerinline constexpr
2445*58b9f456SAndroid Build Coastguard Workerbool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
2446*58b9f456SAndroid Build Coastguard Worker{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
2447*58b9f456SAndroid Build Coastguard Worker
2448*58b9f456SAndroid Build Coastguard Workerinline constexpr
2449*58b9f456SAndroid Build Coastguard Workerbool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
2450*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2451*58b9f456SAndroid Build Coastguard Worker
2452*58b9f456SAndroid Build Coastguard Workerinline constexpr
2453*58b9f456SAndroid Build Coastguard Workerbool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
2454*58b9f456SAndroid Build Coastguard Worker{
2455*58b9f456SAndroid Build Coastguard Worker    if (__lhs.year() < __rhs.year()) return true;
2456*58b9f456SAndroid Build Coastguard Worker    if (__lhs.year() > __rhs.year()) return false;
2457*58b9f456SAndroid Build Coastguard Worker    return __lhs.month_day_last() < __rhs.month_day_last();
2458*58b9f456SAndroid Build Coastguard Worker}
2459*58b9f456SAndroid Build Coastguard Worker
2460*58b9f456SAndroid Build Coastguard Workerinline constexpr
2461*58b9f456SAndroid Build Coastguard Workerbool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
2462*58b9f456SAndroid Build Coastguard Worker{ return __rhs < __lhs; }
2463*58b9f456SAndroid Build Coastguard Worker
2464*58b9f456SAndroid Build Coastguard Workerinline constexpr
2465*58b9f456SAndroid Build Coastguard Workerbool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
2466*58b9f456SAndroid Build Coastguard Worker{ return !(__rhs < __lhs);}
2467*58b9f456SAndroid Build Coastguard Worker
2468*58b9f456SAndroid Build Coastguard Workerinline constexpr
2469*58b9f456SAndroid Build Coastguard Workerbool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
2470*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs < __rhs); }
2471*58b9f456SAndroid Build Coastguard Worker
2472*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
2473*58b9f456SAndroid Build Coastguard Worker{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
2474*58b9f456SAndroid Build Coastguard Worker
2475*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
2476*58b9f456SAndroid Build Coastguard Worker{ return year_month_day_last{__lhs, __rhs}; }
2477*58b9f456SAndroid Build Coastguard Worker
2478*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
2479*58b9f456SAndroid Build Coastguard Worker{ return year_month_day_last{year{__lhs}, __rhs}; }
2480*58b9f456SAndroid Build Coastguard Worker
2481*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept
2482*58b9f456SAndroid Build Coastguard Worker{ return __rhs / __lhs; }
2483*58b9f456SAndroid Build Coastguard Worker
2484*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
2485*58b9f456SAndroid Build Coastguard Worker{ return year{__rhs} / __lhs; }
2486*58b9f456SAndroid Build Coastguard Worker
2487*58b9f456SAndroid Build Coastguard Worker
2488*58b9f456SAndroid Build Coastguard Workerinline constexpr
2489*58b9f456SAndroid Build Coastguard Workeryear_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
2490*58b9f456SAndroid Build Coastguard Worker{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
2491*58b9f456SAndroid Build Coastguard Worker
2492*58b9f456SAndroid Build Coastguard Workerinline constexpr
2493*58b9f456SAndroid Build Coastguard Workeryear_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
2494*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2495*58b9f456SAndroid Build Coastguard Worker
2496*58b9f456SAndroid Build Coastguard Workerinline constexpr
2497*58b9f456SAndroid Build Coastguard Workeryear_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
2498*58b9f456SAndroid Build Coastguard Worker{ return __lhs + (-__rhs); }
2499*58b9f456SAndroid Build Coastguard Worker
2500*58b9f456SAndroid Build Coastguard Workerinline constexpr
2501*58b9f456SAndroid Build Coastguard Workeryear_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
2502*58b9f456SAndroid Build Coastguard Worker{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
2503*58b9f456SAndroid Build Coastguard Worker
2504*58b9f456SAndroid Build Coastguard Workerinline constexpr
2505*58b9f456SAndroid Build Coastguard Workeryear_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
2506*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2507*58b9f456SAndroid Build Coastguard Worker
2508*58b9f456SAndroid Build Coastguard Workerinline constexpr
2509*58b9f456SAndroid Build Coastguard Workeryear_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
2510*58b9f456SAndroid Build Coastguard Worker{ return __lhs + (-__rhs); }
2511*58b9f456SAndroid Build Coastguard Worker
2512*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
2513*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
2514*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy)  noexcept { *this = *this + __dy; return *this; }
2515*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy)  noexcept { *this = *this - __dy; return *this; }
2516*58b9f456SAndroid Build Coastguard Worker
2517*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
2518*58b9f456SAndroid Build Coastguard Worker    : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
2519*58b9f456SAndroid Build Coastguard Worker
2520*58b9f456SAndroid Build Coastguard Workerinline constexpr bool year_month_day::ok() const noexcept
2521*58b9f456SAndroid Build Coastguard Worker{
2522*58b9f456SAndroid Build Coastguard Worker    if (!__y.ok() || !__m.ok()) return false;
2523*58b9f456SAndroid Build Coastguard Worker    return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
2524*58b9f456SAndroid Build Coastguard Worker}
2525*58b9f456SAndroid Build Coastguard Worker
2526*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS year_month_weekday {
2527*58b9f456SAndroid Build Coastguard Worker    chrono::year            __y;
2528*58b9f456SAndroid Build Coastguard Worker    chrono::month           __m;
2529*58b9f456SAndroid Build Coastguard Worker    chrono::weekday_indexed __wdi;
2530*58b9f456SAndroid Build Coastguard Workerpublic:
2531*58b9f456SAndroid Build Coastguard Worker    year_month_weekday() = default;
2532*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
2533*58b9f456SAndroid Build Coastguard Worker                               const chrono::weekday_indexed& __wdival) noexcept
2534*58b9f456SAndroid Build Coastguard Worker        : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
2535*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday(const sys_days& __sysd) noexcept
2536*58b9f456SAndroid Build Coastguard Worker            : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
2537*58b9f456SAndroid Build Coastguard Worker    inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
2538*58b9f456SAndroid Build Coastguard Worker            : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
2539*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday& operator+=(const months& m) noexcept;
2540*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday& operator-=(const months& m) noexcept;
2541*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday& operator+=(const years& y)  noexcept;
2542*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday& operator-=(const years& y)  noexcept;
2543*58b9f456SAndroid Build Coastguard Worker
2544*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::year                       year() const noexcept { return __y; }
2545*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::month                     month() const noexcept { return __m; }
2546*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::weekday                 weekday() const noexcept { return __wdi.weekday(); }
2547*58b9f456SAndroid Build Coastguard Worker    inline constexpr unsigned                          index() const noexcept { return __wdi.index(); }
2548*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
2549*58b9f456SAndroid Build Coastguard Worker
2550*58b9f456SAndroid Build Coastguard Worker    inline constexpr                       operator sys_days() const noexcept { return   sys_days{__to_days()}; }
2551*58b9f456SAndroid Build Coastguard Worker    inline explicit constexpr operator            local_days() const noexcept { return local_days{__to_days()}; }
2552*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool ok() const noexcept
2553*58b9f456SAndroid Build Coastguard Worker    {
2554*58b9f456SAndroid Build Coastguard Worker        if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
2555*58b9f456SAndroid Build Coastguard Worker    //  TODO: make sure it's a valid date
2556*58b9f456SAndroid Build Coastguard Worker        return true;
2557*58b9f456SAndroid Build Coastguard Worker    }
2558*58b9f456SAndroid Build Coastguard Worker
2559*58b9f456SAndroid Build Coastguard Worker    static constexpr year_month_weekday __from_days(days __d) noexcept;
2560*58b9f456SAndroid Build Coastguard Worker    constexpr days __to_days() const noexcept;
2561*58b9f456SAndroid Build Coastguard Worker};
2562*58b9f456SAndroid Build Coastguard Worker
2563*58b9f456SAndroid Build Coastguard Workerinline constexpr
2564*58b9f456SAndroid Build Coastguard Workeryear_month_weekday year_month_weekday::__from_days(days __d) noexcept
2565*58b9f456SAndroid Build Coastguard Worker{
2566*58b9f456SAndroid Build Coastguard Worker    const sys_days      __sysd{__d};
2567*58b9f456SAndroid Build Coastguard Worker    const chrono::weekday __wd = chrono::weekday(__sysd);
2568*58b9f456SAndroid Build Coastguard Worker    const year_month_day __ymd = year_month_day(__sysd);
2569*58b9f456SAndroid Build Coastguard Worker    return year_month_weekday{__ymd.year(), __ymd.month(),
2570*58b9f456SAndroid Build Coastguard Worker                              __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
2571*58b9f456SAndroid Build Coastguard Worker}
2572*58b9f456SAndroid Build Coastguard Worker
2573*58b9f456SAndroid Build Coastguard Workerinline constexpr
2574*58b9f456SAndroid Build Coastguard Workerdays year_month_weekday::__to_days() const noexcept
2575*58b9f456SAndroid Build Coastguard Worker{
2576*58b9f456SAndroid Build Coastguard Worker    const sys_days __sysd = sys_days(__y/__m/1);
2577*58b9f456SAndroid Build Coastguard Worker    return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
2578*58b9f456SAndroid Build Coastguard Worker                .time_since_epoch();
2579*58b9f456SAndroid Build Coastguard Worker}
2580*58b9f456SAndroid Build Coastguard Worker
2581*58b9f456SAndroid Build Coastguard Workerinline constexpr
2582*58b9f456SAndroid Build Coastguard Workerbool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
2583*58b9f456SAndroid Build Coastguard Worker{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
2584*58b9f456SAndroid Build Coastguard Worker
2585*58b9f456SAndroid Build Coastguard Workerinline constexpr
2586*58b9f456SAndroid Build Coastguard Workerbool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
2587*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2588*58b9f456SAndroid Build Coastguard Worker
2589*58b9f456SAndroid Build Coastguard Workerinline constexpr
2590*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
2591*58b9f456SAndroid Build Coastguard Worker{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
2592*58b9f456SAndroid Build Coastguard Worker
2593*58b9f456SAndroid Build Coastguard Workerinline constexpr
2594*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
2595*58b9f456SAndroid Build Coastguard Worker{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
2596*58b9f456SAndroid Build Coastguard Worker
2597*58b9f456SAndroid Build Coastguard Workerinline constexpr
2598*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
2599*58b9f456SAndroid Build Coastguard Worker{ return year(__lhs) / __rhs; }
2600*58b9f456SAndroid Build Coastguard Worker
2601*58b9f456SAndroid Build Coastguard Workerinline constexpr
2602*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
2603*58b9f456SAndroid Build Coastguard Worker{ return __rhs / __lhs; }
2604*58b9f456SAndroid Build Coastguard Worker
2605*58b9f456SAndroid Build Coastguard Workerinline constexpr
2606*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
2607*58b9f456SAndroid Build Coastguard Worker{ return year(__rhs) / __lhs; }
2608*58b9f456SAndroid Build Coastguard Worker
2609*58b9f456SAndroid Build Coastguard Worker
2610*58b9f456SAndroid Build Coastguard Workerinline constexpr
2611*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
2612*58b9f456SAndroid Build Coastguard Worker{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
2613*58b9f456SAndroid Build Coastguard Worker
2614*58b9f456SAndroid Build Coastguard Workerinline constexpr
2615*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
2616*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2617*58b9f456SAndroid Build Coastguard Worker
2618*58b9f456SAndroid Build Coastguard Workerinline constexpr
2619*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
2620*58b9f456SAndroid Build Coastguard Worker{ return __lhs + (-__rhs); }
2621*58b9f456SAndroid Build Coastguard Worker
2622*58b9f456SAndroid Build Coastguard Workerinline constexpr
2623*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
2624*58b9f456SAndroid Build Coastguard Worker{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
2625*58b9f456SAndroid Build Coastguard Worker
2626*58b9f456SAndroid Build Coastguard Workerinline constexpr
2627*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
2628*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2629*58b9f456SAndroid Build Coastguard Worker
2630*58b9f456SAndroid Build Coastguard Workerinline constexpr
2631*58b9f456SAndroid Build Coastguard Workeryear_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
2632*58b9f456SAndroid Build Coastguard Worker{ return __lhs + (-__rhs); }
2633*58b9f456SAndroid Build Coastguard Worker
2634*58b9f456SAndroid Build Coastguard Worker
2635*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
2636*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
2637*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy)  noexcept { *this = *this + __dy; return *this; }
2638*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy)  noexcept { *this = *this - __dy; return *this; }
2639*58b9f456SAndroid Build Coastguard Worker
2640*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS year_month_weekday_last {
2641*58b9f456SAndroid Build Coastguard Workerprivate:
2642*58b9f456SAndroid Build Coastguard Worker    chrono::year         __y;
2643*58b9f456SAndroid Build Coastguard Worker    chrono::month        __m;
2644*58b9f456SAndroid Build Coastguard Worker    chrono::weekday_last __wdl;
2645*58b9f456SAndroid Build Coastguard Workerpublic:
2646*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
2647*58b9f456SAndroid Build Coastguard Worker                                      const chrono::weekday_last& __wdlval) noexcept
2648*58b9f456SAndroid Build Coastguard Worker                : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
2649*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
2650*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
2651*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday_last& operator+=(const years& __dy)  noexcept;
2652*58b9f456SAndroid Build Coastguard Worker    constexpr year_month_weekday_last& operator-=(const years& __dy)  noexcept;
2653*58b9f456SAndroid Build Coastguard Worker
2654*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::year                 year() const noexcept { return __y; }
2655*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::month               month() const noexcept { return __m; }
2656*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::weekday           weekday() const noexcept { return __wdl.weekday(); }
2657*58b9f456SAndroid Build Coastguard Worker    inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
2658*58b9f456SAndroid Build Coastguard Worker    inline constexpr operator                 sys_days() const noexcept { return   sys_days{__to_days()}; }
2659*58b9f456SAndroid Build Coastguard Worker    inline explicit constexpr operator      local_days() const noexcept { return local_days{__to_days()}; }
2660*58b9f456SAndroid Build Coastguard Worker    inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
2661*58b9f456SAndroid Build Coastguard Worker
2662*58b9f456SAndroid Build Coastguard Worker    constexpr days __to_days() const noexcept;
2663*58b9f456SAndroid Build Coastguard Worker
2664*58b9f456SAndroid Build Coastguard Worker};
2665*58b9f456SAndroid Build Coastguard Worker
2666*58b9f456SAndroid Build Coastguard Workerinline constexpr
2667*58b9f456SAndroid Build Coastguard Workerdays year_month_weekday_last::__to_days() const noexcept
2668*58b9f456SAndroid Build Coastguard Worker{
2669*58b9f456SAndroid Build Coastguard Worker    const sys_days __last = sys_days{__y/__m/last};
2670*58b9f456SAndroid Build Coastguard Worker    return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
2671*58b9f456SAndroid Build Coastguard Worker
2672*58b9f456SAndroid Build Coastguard Worker}
2673*58b9f456SAndroid Build Coastguard Worker
2674*58b9f456SAndroid Build Coastguard Workerinline constexpr
2675*58b9f456SAndroid Build Coastguard Workerbool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
2676*58b9f456SAndroid Build Coastguard Worker{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
2677*58b9f456SAndroid Build Coastguard Worker
2678*58b9f456SAndroid Build Coastguard Workerinline constexpr
2679*58b9f456SAndroid Build Coastguard Workerbool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
2680*58b9f456SAndroid Build Coastguard Worker{ return !(__lhs == __rhs); }
2681*58b9f456SAndroid Build Coastguard Worker
2682*58b9f456SAndroid Build Coastguard Worker
2683*58b9f456SAndroid Build Coastguard Workerinline constexpr
2684*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
2685*58b9f456SAndroid Build Coastguard Worker{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
2686*58b9f456SAndroid Build Coastguard Worker
2687*58b9f456SAndroid Build Coastguard Workerinline constexpr
2688*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
2689*58b9f456SAndroid Build Coastguard Worker{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
2690*58b9f456SAndroid Build Coastguard Worker
2691*58b9f456SAndroid Build Coastguard Workerinline constexpr
2692*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
2693*58b9f456SAndroid Build Coastguard Worker{ return year(__lhs) / __rhs; }
2694*58b9f456SAndroid Build Coastguard Worker
2695*58b9f456SAndroid Build Coastguard Workerinline constexpr
2696*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
2697*58b9f456SAndroid Build Coastguard Worker{ return __rhs / __lhs; }
2698*58b9f456SAndroid Build Coastguard Worker
2699*58b9f456SAndroid Build Coastguard Workerinline constexpr
2700*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
2701*58b9f456SAndroid Build Coastguard Worker{ return year(__rhs) / __lhs; }
2702*58b9f456SAndroid Build Coastguard Worker
2703*58b9f456SAndroid Build Coastguard Worker
2704*58b9f456SAndroid Build Coastguard Workerinline constexpr
2705*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
2706*58b9f456SAndroid Build Coastguard Worker{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
2707*58b9f456SAndroid Build Coastguard Worker
2708*58b9f456SAndroid Build Coastguard Workerinline constexpr
2709*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
2710*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2711*58b9f456SAndroid Build Coastguard Worker
2712*58b9f456SAndroid Build Coastguard Workerinline constexpr
2713*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
2714*58b9f456SAndroid Build Coastguard Worker{ return __lhs + (-__rhs); }
2715*58b9f456SAndroid Build Coastguard Worker
2716*58b9f456SAndroid Build Coastguard Workerinline constexpr
2717*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
2718*58b9f456SAndroid Build Coastguard Worker{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
2719*58b9f456SAndroid Build Coastguard Worker
2720*58b9f456SAndroid Build Coastguard Workerinline constexpr
2721*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
2722*58b9f456SAndroid Build Coastguard Worker{ return __rhs + __lhs; }
2723*58b9f456SAndroid Build Coastguard Worker
2724*58b9f456SAndroid Build Coastguard Workerinline constexpr
2725*58b9f456SAndroid Build Coastguard Workeryear_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
2726*58b9f456SAndroid Build Coastguard Worker{ return __lhs + (-__rhs); }
2727*58b9f456SAndroid Build Coastguard Worker
2728*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
2729*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
2730*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy)  noexcept { *this = *this + __dy; return *this; }
2731*58b9f456SAndroid Build Coastguard Workerinline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy)  noexcept { *this = *this - __dy; return *this; }
2732*58b9f456SAndroid Build Coastguard Worker
2733*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER > 17
2734*58b9f456SAndroid Build Coastguard Worker} // chrono
2735*58b9f456SAndroid Build Coastguard Worker
2736*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
2737*58b9f456SAndroid Build Coastguard Worker// Suffixes for duration literals [time.duration.literals]
2738*58b9f456SAndroid Build Coastguard Workerinline namespace literals
2739*58b9f456SAndroid Build Coastguard Worker{
2740*58b9f456SAndroid Build Coastguard Worker  inline namespace chrono_literals
2741*58b9f456SAndroid Build Coastguard Worker  {
2742*58b9f456SAndroid Build Coastguard Worker
2743*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::hours operator""h(unsigned long long __h)
2744*58b9f456SAndroid Build Coastguard Worker    {
2745*58b9f456SAndroid Build Coastguard Worker        return chrono::hours(static_cast<chrono::hours::rep>(__h));
2746*58b9f456SAndroid Build Coastguard Worker    }
2747*58b9f456SAndroid Build Coastguard Worker
2748*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h)
2749*58b9f456SAndroid Build Coastguard Worker    {
2750*58b9f456SAndroid Build Coastguard Worker        return chrono::duration<long double, ratio<3600,1>>(__h);
2751*58b9f456SAndroid Build Coastguard Worker    }
2752*58b9f456SAndroid Build Coastguard Worker
2753*58b9f456SAndroid Build Coastguard Worker
2754*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::minutes operator""min(unsigned long long __m)
2755*58b9f456SAndroid Build Coastguard Worker    {
2756*58b9f456SAndroid Build Coastguard Worker        return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
2757*58b9f456SAndroid Build Coastguard Worker    }
2758*58b9f456SAndroid Build Coastguard Worker
2759*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m)
2760*58b9f456SAndroid Build Coastguard Worker    {
2761*58b9f456SAndroid Build Coastguard Worker        return chrono::duration<long double, ratio<60,1>> (__m);
2762*58b9f456SAndroid Build Coastguard Worker    }
2763*58b9f456SAndroid Build Coastguard Worker
2764*58b9f456SAndroid Build Coastguard Worker
2765*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::seconds operator""s(unsigned long long __s)
2766*58b9f456SAndroid Build Coastguard Worker    {
2767*58b9f456SAndroid Build Coastguard Worker        return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
2768*58b9f456SAndroid Build Coastguard Worker    }
2769*58b9f456SAndroid Build Coastguard Worker
2770*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::duration<long double> operator""s(long double __s)
2771*58b9f456SAndroid Build Coastguard Worker    {
2772*58b9f456SAndroid Build Coastguard Worker        return chrono::duration<long double> (__s);
2773*58b9f456SAndroid Build Coastguard Worker    }
2774*58b9f456SAndroid Build Coastguard Worker
2775*58b9f456SAndroid Build Coastguard Worker
2776*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
2777*58b9f456SAndroid Build Coastguard Worker    {
2778*58b9f456SAndroid Build Coastguard Worker        return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
2779*58b9f456SAndroid Build Coastguard Worker    }
2780*58b9f456SAndroid Build Coastguard Worker
2781*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::duration<long double, milli> operator""ms(long double __ms)
2782*58b9f456SAndroid Build Coastguard Worker    {
2783*58b9f456SAndroid Build Coastguard Worker        return chrono::duration<long double, milli>(__ms);
2784*58b9f456SAndroid Build Coastguard Worker    }
2785*58b9f456SAndroid Build Coastguard Worker
2786*58b9f456SAndroid Build Coastguard Worker
2787*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::microseconds operator""us(unsigned long long __us)
2788*58b9f456SAndroid Build Coastguard Worker    {
2789*58b9f456SAndroid Build Coastguard Worker        return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
2790*58b9f456SAndroid Build Coastguard Worker    }
2791*58b9f456SAndroid Build Coastguard Worker
2792*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::duration<long double, micro> operator""us(long double __us)
2793*58b9f456SAndroid Build Coastguard Worker    {
2794*58b9f456SAndroid Build Coastguard Worker        return chrono::duration<long double, micro> (__us);
2795*58b9f456SAndroid Build Coastguard Worker    }
2796*58b9f456SAndroid Build Coastguard Worker
2797*58b9f456SAndroid Build Coastguard Worker
2798*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::nanoseconds operator""ns(unsigned long long __ns)
2799*58b9f456SAndroid Build Coastguard Worker    {
2800*58b9f456SAndroid Build Coastguard Worker        return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
2801*58b9f456SAndroid Build Coastguard Worker    }
2802*58b9f456SAndroid Build Coastguard Worker
2803*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
2804*58b9f456SAndroid Build Coastguard Worker    {
2805*58b9f456SAndroid Build Coastguard Worker        return chrono::duration<long double, nano> (__ns);
2806*58b9f456SAndroid Build Coastguard Worker    }
2807*58b9f456SAndroid Build Coastguard Worker
2808*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS)
2809*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::day operator ""d(unsigned long long __d) noexcept
2810*58b9f456SAndroid Build Coastguard Worker    {
2811*58b9f456SAndroid Build Coastguard Worker        return chrono::day(static_cast<unsigned>(__d));
2812*58b9f456SAndroid Build Coastguard Worker    }
2813*58b9f456SAndroid Build Coastguard Worker
2814*58b9f456SAndroid Build Coastguard Worker    constexpr chrono::year operator ""y(unsigned long long __y) noexcept
2815*58b9f456SAndroid Build Coastguard Worker    {
2816*58b9f456SAndroid Build Coastguard Worker        return chrono::year(static_cast<int>(__y));
2817*58b9f456SAndroid Build Coastguard Worker    }
2818*58b9f456SAndroid Build Coastguard Worker#endif
2819*58b9f456SAndroid Build Coastguard Worker}}
2820*58b9f456SAndroid Build Coastguard Worker
2821*58b9f456SAndroid Build Coastguard Workernamespace chrono { // hoist the literals into namespace std::chrono
2822*58b9f456SAndroid Build Coastguard Worker   using namespace literals::chrono_literals;
2823*58b9f456SAndroid Build Coastguard Worker}
2824*58b9f456SAndroid Build Coastguard Worker
2825*58b9f456SAndroid Build Coastguard Worker#endif
2826*58b9f456SAndroid Build Coastguard Worker
2827*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
2828*58b9f456SAndroid Build Coastguard Worker
2829*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
2830*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
2831*58b9f456SAndroid Build Coastguard Workerstruct _FilesystemClock {
2832*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_INT128)
2833*58b9f456SAndroid Build Coastguard Worker  typedef __int128_t rep;
2834*58b9f456SAndroid Build Coastguard Worker  typedef nano period;
2835*58b9f456SAndroid Build Coastguard Worker#else
2836*58b9f456SAndroid Build Coastguard Worker  typedef long long rep;
2837*58b9f456SAndroid Build Coastguard Worker  typedef nano period;
2838*58b9f456SAndroid Build Coastguard Worker#endif
2839*58b9f456SAndroid Build Coastguard Worker
2840*58b9f456SAndroid Build Coastguard Worker  typedef chrono::duration<rep, period> duration;
2841*58b9f456SAndroid Build Coastguard Worker  typedef chrono::time_point<_FilesystemClock> time_point;
2842*58b9f456SAndroid Build Coastguard Worker
2843*58b9f456SAndroid Build Coastguard Worker  static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
2844*58b9f456SAndroid Build Coastguard Worker
2845*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS static time_point now() noexcept;
2846*58b9f456SAndroid Build Coastguard Worker
2847*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2848*58b9f456SAndroid Build Coastguard Worker  static time_t to_time_t(const time_point& __t) noexcept {
2849*58b9f456SAndroid Build Coastguard Worker      typedef chrono::duration<rep> __secs;
2850*58b9f456SAndroid Build Coastguard Worker      return time_t(
2851*58b9f456SAndroid Build Coastguard Worker          chrono::duration_cast<__secs>(__t.time_since_epoch()).count());
2852*58b9f456SAndroid Build Coastguard Worker  }
2853*58b9f456SAndroid Build Coastguard Worker
2854*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2855*58b9f456SAndroid Build Coastguard Worker  static time_point from_time_t(time_t __t) noexcept {
2856*58b9f456SAndroid Build Coastguard Worker      typedef chrono::duration<rep> __secs;
2857*58b9f456SAndroid Build Coastguard Worker      return time_point(__secs(__t));
2858*58b9f456SAndroid Build Coastguard Worker  }
2859*58b9f456SAndroid Build Coastguard Worker};
2860*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_FILESYSTEM
2861*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG
2862*58b9f456SAndroid Build Coastguard Worker
2863*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS
2864*58b9f456SAndroid Build Coastguard Worker
2865*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CHRONO
2866