xref: /freebsd/contrib/llvm-project/libcxx/include/chrono (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_CHRONO
11#define _LIBCPP_CHRONO
12
13/*
14    chrono synopsis
15
16#include <compare> // C++20
17
18namespace std
19{
20namespace chrono
21{
22
23template <class ToDuration, class Rep, class Period>
24constexpr
25ToDuration
26duration_cast(const duration<Rep, Period>& fd);
27
28template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
29
30template <class Rep> inline constexpr bool treat_as_floating_point_v
31    = treat_as_floating_point<Rep>::value;                       // C++17
32
33template <class Rep>
34struct duration_values
35{
36public:
37    static constexpr Rep zero(); // noexcept in C++20
38    static constexpr Rep max();  // noexcept in C++20
39    static constexpr Rep min();  // noexcept in C++20
40};
41
42// duration
43
44template <class Rep, class Period = ratio<1>>
45class duration
46{
47    static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
48    static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
49    static_assert(Period::num > 0, "duration period must be positive");
50public:
51    typedef Rep rep;
52    typedef typename _Period::type period;
53
54    constexpr duration() = default;
55    template <class Rep2>
56        constexpr explicit duration(const Rep2& r,
57            typename enable_if
58            <
59               is_convertible<Rep2, rep>::value &&
60               (treat_as_floating_point<rep>::value ||
61               !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
62            >::type* = 0);
63
64    // conversions
65    template <class Rep2, class Period2>
66        constexpr duration(const duration<Rep2, Period2>& d,
67            typename enable_if
68            <
69                treat_as_floating_point<rep>::value ||
70                ratio_divide<Period2, period>::type::den == 1
71            >::type* = 0);
72
73    // observer
74
75    constexpr rep count() const;
76
77    // arithmetic
78
79    constexpr common_type<duration>::type  operator+() const;
80    constexpr common_type<duration>::type  operator-() const;
81    constexpr duration& operator++();    // constexpr in C++17
82    constexpr duration  operator++(int); // constexpr in C++17
83    constexpr duration& operator--();    // constexpr in C++17
84    constexpr duration  operator--(int); // constexpr in C++17
85
86    constexpr duration& operator+=(const duration& d);  // constexpr in C++17
87    constexpr duration& operator-=(const duration& d);  // constexpr in C++17
88
89    duration& operator*=(const rep& rhs);       // constexpr in C++17
90    duration& operator/=(const rep& rhs);       // constexpr in C++17
91    duration& operator%=(const rep& rhs);       // constexpr in C++17
92    duration& operator%=(const duration& rhs);  // constexpr in C++17
93
94    // special values
95
96    static constexpr duration zero(); // noexcept in C++20
97    static constexpr duration min();  // noexcept in C++20
98    static constexpr duration max();  // noexcept in C++20
99};
100
101typedef duration<long long,         nano> nanoseconds;
102typedef duration<long long,        micro> microseconds;
103typedef duration<long long,        milli> milliseconds;
104typedef duration<long long              > seconds;
105typedef duration<     long, ratio<  60> > minutes;
106typedef duration<     long, ratio<3600> > hours;
107
108template <class Clock, class Duration = typename Clock::duration>
109class time_point
110{
111public:
112    typedef Clock                     clock;
113    typedef Duration                  duration;
114    typedef typename duration::rep    rep;
115    typedef typename duration::period period;
116private:
117    duration d_;  // exposition only
118
119public:
120    time_point();  // has value "epoch" // constexpr in C++14
121    explicit time_point(const duration& d);  // same as time_point() + d // constexpr in C++14
122
123    // conversions
124    template <class Duration2>
125       time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
126
127    // observer
128
129    duration time_since_epoch() const; // constexpr in C++14
130
131    // arithmetic
132
133    time_point& operator+=(const duration& d); // constexpr in C++17
134    time_point& operator-=(const duration& d); // constexpr in C++17
135
136    // special values
137
138    static constexpr time_point min();  // noexcept in C++20
139    static constexpr time_point max();  // noexcept in C++20
140};
141
142} // chrono
143
144// common_type traits
145template <class Rep1, class Period1, class Rep2, class Period2>
146  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
147
148template <class Clock, class Duration1, class Duration2>
149  struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
150
151namespace chrono {
152
153// duration arithmetic
154template <class Rep1, class Period1, class Rep2, class Period2>
155  constexpr
156  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
157  operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
158template <class Rep1, class Period1, class Rep2, class Period2>
159  constexpr
160  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
161  operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
162template <class Rep1, class Period, class Rep2>
163  constexpr
164  duration<typename common_type<Rep1, Rep2>::type, Period>
165  operator*(const duration<Rep1, Period>& d, const Rep2& s);
166template <class Rep1, class Period, class Rep2>
167  constexpr
168  duration<typename common_type<Rep1, Rep2>::type, Period>
169  operator*(const Rep1& s, const duration<Rep2, Period>& d);
170template <class Rep1, class Period, class Rep2>
171  constexpr
172  duration<typename common_type<Rep1, Rep2>::type, Period>
173  operator/(const duration<Rep1, Period>& d, const Rep2& s);
174template <class Rep1, class Period1, class Rep2, class Period2>
175  constexpr
176  typename common_type<Rep1, Rep2>::type
177  operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
178
179// duration comparisons
180template <class Rep1, class Period1, class Rep2, class Period2>
181   constexpr
182   bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
183template <class Rep1, class Period1, class Rep2, class Period2>
184   constexpr
185   bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
186template <class Rep1, class Period1, class Rep2, class Period2>
187   constexpr
188   bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
189template <class Rep1, class Period1, class Rep2, class Period2>
190   constexpr
191   bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
192template <class Rep1, class Period1, class Rep2, class Period2>
193   constexpr
194   bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
195template <class Rep1, class Period1, class Rep2, class Period2>
196   constexpr
197   bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
198
199// duration_cast
200template <class ToDuration, class Rep, class Period>
201  ToDuration duration_cast(const duration<Rep, Period>& d);
202
203template <class ToDuration, class Rep, class Period>
204    constexpr ToDuration floor(const duration<Rep, Period>& d);    // C++17
205template <class ToDuration, class Rep, class Period>
206    constexpr ToDuration ceil(const duration<Rep, Period>& d);     // C++17
207template <class ToDuration, class Rep, class Period>
208    constexpr ToDuration round(const duration<Rep, Period>& d);    // C++17
209
210// duration I/O is elsewhere
211
212// time_point arithmetic (all constexpr in C++14)
213template <class Clock, class Duration1, class Rep2, class Period2>
214  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
215  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
216template <class Rep1, class Period1, class Clock, class Duration2>
217  time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
218  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
219template <class Clock, class Duration1, class Rep2, class Period2>
220  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
221  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
222template <class Clock, class Duration1, class Duration2>
223  typename common_type<Duration1, Duration2>::type
224  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
225
226// time_point comparisons (all constexpr in C++14)
227template <class Clock, class Duration1, class Duration2>
228   bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
229template <class Clock, class Duration1, class Duration2>
230   bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
231template <class Clock, class Duration1, class Duration2>
232   bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
233template <class Clock, class Duration1, class Duration2>
234   bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
235template <class Clock, class Duration1, class Duration2>
236   bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
237template <class Clock, class Duration1, class Duration2>
238   bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
239
240// time_point_cast (constexpr in C++14)
241
242template <class ToDuration, class Clock, class Duration>
243  time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
244
245template <class ToDuration, class Clock, class Duration>
246    constexpr time_point<Clock, ToDuration>
247    floor(const time_point<Clock, Duration>& tp);                  // C++17
248
249template <class ToDuration, class Clock, class Duration>
250    constexpr time_point<Clock, ToDuration>
251    ceil(const time_point<Clock, Duration>& tp);                   // C++17
252
253template <class ToDuration, class Clock, class Duration>
254    constexpr time_point<Clock, ToDuration>
255    round(const time_point<Clock, Duration>& tp);                  // C++17
256
257template <class Rep, class Period>
258    constexpr duration<Rep, Period> abs(duration<Rep, Period> d);  // C++17
259
260// Clocks
261
262class system_clock
263{
264public:
265    typedef microseconds                     duration;
266    typedef duration::rep                    rep;
267    typedef duration::period                 period;
268    typedef chrono::time_point<system_clock> time_point;
269    static const bool is_steady =            false; // constexpr in C++14
270
271    static time_point now() noexcept;
272    static time_t     to_time_t  (const time_point& __t) noexcept;
273    static time_point from_time_t(time_t __t) noexcept;
274};
275
276template <class Duration>
277  using sys_time  = time_point<system_clock, Duration>; // C++20
278using sys_seconds = sys_time<seconds>;                  // C++20
279using sys_days    = sys_time<days>;                     // C++20
280
281class file_clock                                        // C++20
282{
283public:
284    typedef see-below                      rep;
285    typedef nano                           period;
286    typedef chrono::duration<rep, period>  duration;
287    typedef chrono::time_point<file_clock> time_point;
288    static constexpr bool is_steady =      false;
289
290    static time_point now() noexcept;
291
292    template<class Duration>
293    static sys_time<see-below> to_sys(const file_time<Duration>&);
294
295    template<class Duration>
296    static file_time<see-below> from_sys(const sys_time<Duration>&);
297};
298
299template<class Duration>
300  using file_time = time_point<file_clock, Duration>;   // C++20
301
302class steady_clock
303{
304public:
305    typedef nanoseconds                                   duration;
306    typedef duration::rep                                 rep;
307    typedef duration::period                              period;
308    typedef chrono::time_point<steady_clock, duration>    time_point;
309    static const bool is_steady =                         true; // constexpr in C++14
310
311    static time_point now() noexcept;
312};
313
314typedef steady_clock high_resolution_clock;
315
316// 25.7.8, local time           // C++20
317struct local_t {};
318template<class Duration>
319  using local_time  = time_point<local_t, Duration>;
320using local_seconds = local_time<seconds>;
321using local_days    = local_time<days>;
322
323// 25.8.2, class last_spec    // C++20
324struct last_spec;
325
326// 25.8.3, class day          // C++20
327
328class day;
329constexpr bool operator==(const day& x, const day& y) noexcept;
330constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
331constexpr day  operator+(const day&  x, const days& y) noexcept;
332constexpr day  operator+(const days& x, const day&  y) noexcept;
333constexpr day  operator-(const day&  x, const days& y) noexcept;
334constexpr days operator-(const day&  x, const day&  y) noexcept;
335
336// 25.8.4, class month    // C++20
337class month;
338constexpr bool operator==(const month& x, const month& y) noexcept;
339constexpr bool operator!=(const month& x, const month& y) noexcept;
340constexpr bool operator< (const month& x, const month& y) noexcept;
341constexpr bool operator> (const month& x, const month& y) noexcept;
342constexpr bool operator<=(const month& x, const month& y) noexcept;
343constexpr bool operator>=(const month& x, const month& y) noexcept;
344constexpr month  operator+(const month&  x, const months& y) noexcept;
345constexpr month  operator+(const months& x,  const month& y) noexcept;
346constexpr month  operator-(const month&  x, const months& y) noexcept;
347constexpr months operator-(const month&  x,  const month& y) noexcept;
348
349// 25.8.5, class year    // C++20
350class year;
351constexpr bool operator==(const year& x, const year& y) noexcept;
352constexpr bool operator!=(const year& x, const year& y) noexcept;
353constexpr bool operator< (const year& x, const year& y) noexcept;
354constexpr bool operator> (const year& x, const year& y) noexcept;
355constexpr bool operator<=(const year& x, const year& y) noexcept;
356constexpr bool operator>=(const year& x, const year& y) noexcept;
357constexpr year  operator+(const year&  x, const years& y) noexcept;
358constexpr year  operator+(const years& x, const year&  y) noexcept;
359constexpr year  operator-(const year&  x, const years& y) noexcept;
360constexpr years operator-(const year&  x, const year&  y) noexcept;
361
362// 25.8.6, class weekday    // C++20
363class weekday;
364
365constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
366constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
367constexpr weekday operator+(const weekday& x, const days&    y) noexcept;
368constexpr weekday operator+(const days&    x, const weekday& y) noexcept;
369constexpr weekday operator-(const weekday& x, const days&    y) noexcept;
370constexpr days    operator-(const weekday& x, const weekday& y) noexcept;
371
372// 25.8.7, class weekday_indexed    // C++20
373
374class weekday_indexed;
375constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
376constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
377
378// 25.8.8, class weekday_last    // C++20
379class weekday_last;
380
381constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
382constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
383
384// 25.8.9, class month_day    // C++20
385class month_day;
386
387constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
388constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
389constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
390constexpr bool operator> (const month_day& x, const month_day& y) noexcept;
391constexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
392constexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
393
394
395// 25.8.10, class month_day_last    // C++20
396class month_day_last;
397
398constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
399constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
400constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
401constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
402constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
403constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
404
405// 25.8.11, class month_weekday    // C++20
406class month_weekday;
407
408constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
409constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;
410
411// 25.8.12, class month_weekday_last    // C++20
412class month_weekday_last;
413
414constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
415constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;
416
417
418// 25.8.13, class year_month    // C++20
419class year_month;
420
421constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
422constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
423constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
424constexpr bool operator> (const year_month& x, const year_month& y) noexcept;
425constexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
426constexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
427
428constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
429constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
430constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
431constexpr months operator-(const year_month& x, const year_month& y) noexcept;
432constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
433constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
434constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
435
436// 25.8.14, class year_month_day class    // C++20
437year_month_day;
438
439constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
440constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
441constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
442constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
443constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
444constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
445
446constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
447constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
448constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
449constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
450constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
451constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
452
453
454// 25.8.15, class year_month_day_last    // C++20
455class year_month_day_last;
456
457constexpr bool operator==(const year_month_day_last& x,
458                          const year_month_day_last& y) noexcept;
459constexpr bool operator!=(const year_month_day_last& x,
460                          const year_month_day_last& y) noexcept;
461constexpr bool operator< (const year_month_day_last& x,
462                          const year_month_day_last& y) noexcept;
463constexpr bool operator> (const year_month_day_last& x,
464                          const year_month_day_last& y) noexcept;
465constexpr bool operator<=(const year_month_day_last& x,
466                          const year_month_day_last& y) noexcept;
467constexpr bool operator>=(const year_month_day_last& x,
468                          const year_month_day_last& y) noexcept;
469
470constexpr year_month_day_last
471  operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
472constexpr year_month_day_last
473  operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
474constexpr year_month_day_last
475  operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
476constexpr year_month_day_last
477  operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
478constexpr year_month_day_last
479  operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
480constexpr year_month_day_last
481  operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
482
483// 25.8.16, class year_month_weekday    // C++20
484class year_month_weekday;
485
486constexpr bool operator==(const year_month_weekday& x,
487                          const year_month_weekday& y) noexcept;
488constexpr bool operator!=(const year_month_weekday& x,
489                          const year_month_weekday& y) noexcept;
490
491constexpr year_month_weekday
492  operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
493constexpr year_month_weekday
494  operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
495constexpr year_month_weekday
496  operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
497constexpr year_month_weekday
498  operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
499constexpr year_month_weekday
500  operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
501constexpr year_month_weekday
502  operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
503
504// 25.8.17, class year_month_weekday_last    // C++20
505class year_month_weekday_last;
506
507constexpr bool operator==(const year_month_weekday_last& x,
508                          const year_month_weekday_last& y) noexcept;
509constexpr bool operator!=(const year_month_weekday_last& x,
510                          const year_month_weekday_last& y) noexcept;
511constexpr year_month_weekday_last
512  operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
513constexpr year_month_weekday_last
514  operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
515constexpr year_month_weekday_last
516  operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
517constexpr year_month_weekday_last
518  operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
519constexpr year_month_weekday_last
520  operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
521constexpr year_month_weekday_last
522  operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
523
524// 25.8.18, civil calendar conventional syntax operators    // C++20
525constexpr year_month
526  operator/(const year& y, const month& m) noexcept;
527constexpr year_month
528  operator/(const year& y, int m) noexcept;
529constexpr month_day
530  operator/(const month& m, const day& d) noexcept;
531constexpr month_day
532  operator/(const month& m, int d) noexcept;
533constexpr month_day
534  operator/(int m, const day& d) noexcept;
535constexpr month_day
536  operator/(const day& d, const month& m) noexcept;
537constexpr month_day
538  operator/(const day& d, int m) noexcept;
539constexpr month_day_last
540  operator/(const month& m, last_spec) noexcept;
541constexpr month_day_last
542  operator/(int m, last_spec) noexcept;
543constexpr month_day_last
544  operator/(last_spec, const month& m) noexcept;
545constexpr month_day_last
546  operator/(last_spec, int m) noexcept;
547constexpr month_weekday
548  operator/(const month& m, const weekday_indexed& wdi) noexcept;
549constexpr month_weekday
550  operator/(int m, const weekday_indexed& wdi) noexcept;
551constexpr month_weekday
552  operator/(const weekday_indexed& wdi, const month& m) noexcept;
553constexpr month_weekday
554  operator/(const weekday_indexed& wdi, int m) noexcept;
555constexpr month_weekday_last
556  operator/(const month& m, const weekday_last& wdl) noexcept;
557constexpr month_weekday_last
558  operator/(int m, const weekday_last& wdl) noexcept;
559constexpr month_weekday_last
560  operator/(const weekday_last& wdl, const month& m) noexcept;
561constexpr month_weekday_last
562  operator/(const weekday_last& wdl, int m) noexcept;
563constexpr year_month_day
564  operator/(const year_month& ym, const day& d) noexcept;
565constexpr year_month_day
566  operator/(const year_month& ym, int d) noexcept;
567constexpr year_month_day
568  operator/(const year& y, const month_day& md) noexcept;
569constexpr year_month_day
570  operator/(int y, const month_day& md) noexcept;
571constexpr year_month_day
572  operator/(const month_day& md, const year& y) noexcept;
573constexpr year_month_day
574  operator/(const month_day& md, int y) noexcept;
575constexpr year_month_day_last
576  operator/(const year_month& ym, last_spec) noexcept;
577constexpr year_month_day_last
578  operator/(const year& y, const month_day_last& mdl) noexcept;
579constexpr year_month_day_last
580  operator/(int y, const month_day_last& mdl) noexcept;
581constexpr year_month_day_last
582  operator/(const month_day_last& mdl, const year& y) noexcept;
583constexpr year_month_day_last
584  operator/(const month_day_last& mdl, int y) noexcept;
585constexpr year_month_weekday
586  operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
587constexpr year_month_weekday
588  operator/(const year& y, const month_weekday& mwd) noexcept;
589constexpr year_month_weekday
590  operator/(int y, const month_weekday& mwd) noexcept;
591constexpr year_month_weekday
592  operator/(const month_weekday& mwd, const year& y) noexcept;
593constexpr year_month_weekday
594  operator/(const month_weekday& mwd, int y) noexcept;
595constexpr year_month_weekday_last
596  operator/(const year_month& ym, const weekday_last& wdl) noexcept;
597constexpr year_month_weekday_last
598  operator/(const year& y, const month_weekday_last& mwdl) noexcept;
599constexpr year_month_weekday_last
600  operator/(int y, const month_weekday_last& mwdl) noexcept;
601constexpr year_month_weekday_last
602  operator/(const month_weekday_last& mwdl, const year& y) noexcept;
603constexpr year_month_weekday_last
604  operator/(const month_weekday_last& mwdl, int y) noexcept;
605
606// 26.9, class template hh_mm_ss
607template <class Duration>
608class hh_mm_ss
609{
610    bool            is_neg; // exposition only
611    chrono::hours   h;      // exposition only
612    chrono::minutes m;      // exposition only
613    chrono::seconds s;      // exposition only
614    precision       ss;     // exposition only
615
616public:
617    static unsigned constexpr fractional_width = see below;
618    using precision                            = see below;
619
620    constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
621    constexpr explicit hh_mm_ss(Duration d) noexcept;
622
623    constexpr bool is_negative() const noexcept;
624    constexpr chrono::hours hours() const noexcept;
625    constexpr chrono::minutes minutes() const noexcept;
626    constexpr chrono::seconds seconds() const noexcept;
627    constexpr precision subseconds() const noexcept;
628
629    constexpr explicit operator  precision()   const noexcept;
630    constexpr          precision to_duration() const noexcept;
631};
632
633// 26.10, 12/24 hour functions
634constexpr bool is_am(hours const& h) noexcept;
635constexpr bool is_pm(hours const& h) noexcept;
636constexpr hours make12(const hours& h) noexcept;
637constexpr hours make24(const hours& h, bool is_pm) noexcept;
638
639// 25.10.5, class time_zone    // C++20
640enum class choose {earliest, latest};
641class time_zone;
642bool operator==(const time_zone& x, const time_zone& y) noexcept;
643bool operator!=(const time_zone& x, const time_zone& y) noexcept;
644bool operator<(const time_zone& x, const time_zone& y) noexcept;
645bool operator>(const time_zone& x, const time_zone& y) noexcept;
646bool operator<=(const time_zone& x, const time_zone& y) noexcept;
647bool operator>=(const time_zone& x, const time_zone& y) noexcept;
648
649// calendrical constants
650inline constexpr last_spec                              last{};       // C++20
651inline constexpr chrono::weekday                        Sunday{0};    // C++20
652inline constexpr chrono::weekday                        Monday{1};    // C++20
653inline constexpr chrono::weekday                        Tuesday{2};   // C++20
654inline constexpr chrono::weekday                        Wednesday{3}; // C++20
655inline constexpr chrono::weekday                        Thursday{4};  // C++20
656inline constexpr chrono::weekday                        Friday{5};    // C++20
657inline constexpr chrono::weekday                        Saturday{6};  // C++20
658
659inline constexpr chrono::month                          January{1};   // C++20
660inline constexpr chrono::month                          February{2};  // C++20
661inline constexpr chrono::month                          March{3};     // C++20
662inline constexpr chrono::month                          April{4};     // C++20
663inline constexpr chrono::month                          May{5};       // C++20
664inline constexpr chrono::month                          June{6};      // C++20
665inline constexpr chrono::month                          July{7};      // C++20
666inline constexpr chrono::month                          August{8};    // C++20
667inline constexpr chrono::month                          September{9}; // C++20
668inline constexpr chrono::month                          October{10};  // C++20
669inline constexpr chrono::month                          November{11}; // C++20
670inline constexpr chrono::month                          December{12}; // C++20
671}  // chrono
672
673inline namespace literals {
674  inline namespace chrono_literals {
675constexpr chrono::hours                                 operator ""h(unsigned long long); // C++14
676constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
677constexpr chrono::minutes                               operator ""min(unsigned long long); // C++14
678constexpr chrono::duration<unspecified , ratio<60,1>>   operator ""min(long double); // C++14
679constexpr chrono::seconds                               operator ""s(unsigned long long); // C++14
680constexpr chrono::duration<unspecified >                operator ""s(long double); // C++14
681constexpr chrono::milliseconds                          operator ""ms(unsigned long long); // C++14
682constexpr chrono::duration<unspecified , milli>         operator ""ms(long double); // C++14
683constexpr chrono::microseconds                          operator ""us(unsigned long long); // C++14
684constexpr chrono::duration<unspecified , micro>         operator ""us(long double); // C++14
685constexpr chrono::nanoseconds                           operator ""ns(unsigned long long); // C++14
686constexpr chrono::duration<unspecified , nano>          operator ""ns(long double); // C++14
687constexpr chrono::day                                   operator ""d(unsigned long long d) noexcept; // C++20
688constexpr chrono::year                                  operator ""y(unsigned long long y) noexcept; // C++20
689}  // chrono_literals
690}  // literals
691
692}  // std
693*/
694
695#include <__assert> // all public C++ headers provide the assertion handler
696#include <__chrono/calendar.h>
697#include <__chrono/convert_to_timespec.h>
698#include <__chrono/day.h>
699#include <__chrono/duration.h>
700#include <__chrono/file_clock.h>
701#include <__chrono/hh_mm_ss.h>
702#include <__chrono/high_resolution_clock.h>
703#include <__chrono/literals.h>
704#include <__chrono/month.h>
705#include <__chrono/month_weekday.h>
706#include <__chrono/monthday.h>
707#include <__chrono/steady_clock.h>
708#include <__chrono/system_clock.h>
709#include <__chrono/time_point.h>
710#include <__chrono/weekday.h>
711#include <__chrono/year.h>
712#include <__chrono/year_month.h>
713#include <__chrono/year_month_day.h>
714#include <__chrono/year_month_weekday.h>
715#include <__config>
716#include <version>
717
718// standard-mandated includes
719#include <compare>
720
721#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
722#  pragma GCC system_header
723#endif
724
725#endif // _LIBCPP_CHRONO
726