2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_CHRONO
11 #define _LIBCPP_CHRONO
18 #include <compare> // C++20
25 template <class ToDuration, class Rep, class Period>
28 duration_cast(const duration<Rep, Period>& fd);
30 template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
32 template <class Rep> inline constexpr bool treat_as_floating_point_v
33 = treat_as_floating_point<Rep>::value; // C++17
36 struct duration_values
39 static constexpr Rep zero(); // noexcept in C++20
40 static constexpr Rep max(); // noexcept in C++20
41 static constexpr Rep min(); // noexcept in C++20
46 template <class Rep, class Period = ratio<1>>
49 static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
50 static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
51 static_assert(Period::num > 0, "duration period must be positive");
54 typedef typename _Period::type period;
56 constexpr duration() = default;
58 constexpr explicit duration(const Rep2& r,
61 is_convertible<Rep2, rep>::value &&
62 (treat_as_floating_point<rep>::value ||
63 !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
67 template <class Rep2, class Period2>
68 constexpr duration(const duration<Rep2, Period2>& d,
71 treat_as_floating_point<rep>::value ||
72 ratio_divide<Period2, period>::type::den == 1
77 constexpr rep count() const;
81 constexpr common_type<duration>::type operator+() const;
82 constexpr common_type<duration>::type operator-() const;
83 constexpr duration& operator++(); // constexpr in C++17
84 constexpr duration operator++(int); // constexpr in C++17
85 constexpr duration& operator--(); // constexpr in C++17
86 constexpr duration operator--(int); // constexpr in C++17
88 constexpr duration& operator+=(const duration& d); // constexpr in C++17
89 constexpr duration& operator-=(const duration& d); // constexpr in C++17
91 duration& operator*=(const rep& rhs); // constexpr in C++17
92 duration& operator/=(const rep& rhs); // constexpr in C++17
93 duration& operator%=(const rep& rhs); // constexpr in C++17
94 duration& operator%=(const duration& rhs); // constexpr in C++17
98 static constexpr duration zero(); // noexcept in C++20
99 static constexpr duration min(); // noexcept in C++20
100 static constexpr duration max(); // noexcept in C++20
103 typedef duration<long long, nano> nanoseconds;
104 typedef duration<long long, micro> microseconds;
105 typedef duration<long long, milli> milliseconds;
106 typedef duration<long long > seconds;
107 typedef duration< long, ratio< 60> > minutes;
108 typedef duration< long, ratio<3600> > hours;
110 template <class Clock, class Duration = typename Clock::duration>
115 typedef Duration duration;
116 typedef typename duration::rep rep;
117 typedef typename duration::period period;
119 duration d_; // exposition only
122 time_point(); // has value "epoch" // constexpr in C++14
123 explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14
126 template <class Duration2>
127 time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
131 duration time_since_epoch() const; // constexpr in C++14
135 time_point& operator+=(const duration& d); // constexpr in C++17
136 time_point& operator-=(const duration& d); // constexpr in C++17
140 static constexpr time_point min(); // noexcept in C++20
141 static constexpr time_point max(); // noexcept in C++20
146 // common_type traits
147 template <class Rep1, class Period1, class Rep2, class Period2>
148 struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
150 template <class Clock, class Duration1, class Duration2>
151 struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
155 // duration arithmetic
156 template <class Rep1, class Period1, class Rep2, class Period2>
158 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
159 operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
160 template <class Rep1, class Period1, class Rep2, class Period2>
162 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
163 operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
164 template <class Rep1, class Period, class Rep2>
166 duration<typename common_type<Rep1, Rep2>::type, Period>
167 operator*(const duration<Rep1, Period>& d, const Rep2& s);
168 template <class Rep1, class Period, class Rep2>
170 duration<typename common_type<Rep1, Rep2>::type, Period>
171 operator*(const Rep1& s, const duration<Rep2, Period>& d);
172 template <class Rep1, class Period, class Rep2>
174 duration<typename common_type<Rep1, Rep2>::type, Period>
175 operator/(const duration<Rep1, Period>& d, const Rep2& s);
176 template <class Rep1, class Period1, class Rep2, class Period2>
178 typename common_type<Rep1, Rep2>::type
179 operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
181 // duration comparisons
182 template <class Rep1, class Period1, class Rep2, class Period2>
184 bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
185 template <class Rep1, class Period1, class Rep2, class Period2>
187 bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); // removed in C++20
188 template <class Rep1, class Period1, class Rep2, class Period2>
190 bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
191 template <class Rep1, class Period1, class Rep2, class Period2>
193 bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
194 template <class Rep1, class Period1, class Rep2, class Period2>
196 bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
197 template <class Rep1, class Period1, class Rep2, class Period2>
199 bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
200 template<class Rep1, class Period1, class Rep2, class Period2>
201 requires three_way_comparable<typename CT::rep>
202 constexpr auto operator<=>(const duration<Rep1, Period1>& lhs,
203 const duration<Rep2, Period2>& rhs); // since C++20
206 template <class ToDuration, class Rep, class Period>
207 ToDuration duration_cast(const duration<Rep, Period>& d);
209 template <class ToDuration, class Rep, class Period>
210 constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17
211 template <class ToDuration, class Rep, class Period>
212 constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17
213 template <class ToDuration, class Rep, class Period>
214 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
217 template<class charT, class traits, class Rep, class Period> // C++20
218 basic_ostream<charT, traits>&
219 operator<<(basic_ostream<charT, traits>& os,
220 const duration<Rep, Period>& d);
222 // time_point arithmetic (all constexpr in C++14)
223 template <class Clock, class Duration1, class Rep2, class Period2>
224 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
225 operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
226 template <class Rep1, class Period1, class Clock, class Duration2>
227 time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
228 operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
229 template <class Clock, class Duration1, class Rep2, class Period2>
230 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
231 operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
232 template <class Clock, class Duration1, class Duration2>
233 typename common_type<Duration1, Duration2>::type
234 operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
236 // time_point comparisons (all constexpr in C++14)
237 template <class Clock, class Duration1, class Duration2>
238 bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
239 template <class Clock, class Duration1, class Duration2>
240 bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); // removed in C++20
241 template <class Clock, class Duration1, class Duration2>
242 bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
243 template <class Clock, class Duration1, class Duration2>
244 bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
245 template <class Clock, class Duration1, class Duration2>
246 bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
247 template <class Clock, class Duration1, class Duration2>
248 bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
249 template<class Clock, class Duration1,
250 three_way_comparable_with<Duration1> Duration2>
251 constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs,
252 const time_point<Clock, Duration2>& rhs); // since C++20
254 // time_point_cast (constexpr in C++14)
256 template <class ToDuration, class Clock, class Duration>
257 time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
259 template <class ToDuration, class Clock, class Duration>
260 constexpr time_point<Clock, ToDuration>
261 floor(const time_point<Clock, Duration>& tp); // C++17
263 template <class ToDuration, class Clock, class Duration>
264 constexpr time_point<Clock, ToDuration>
265 ceil(const time_point<Clock, Duration>& tp); // C++17
267 template <class ToDuration, class Clock, class Duration>
268 constexpr time_point<Clock, ToDuration>
269 round(const time_point<Clock, Duration>& tp); // C++17
271 template <class Rep, class Period>
272 constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17
279 typedef microseconds duration;
280 typedef duration::rep rep;
281 typedef duration::period period;
282 typedef chrono::time_point<system_clock> time_point;
283 static const bool is_steady = false; // constexpr in C++14
285 static time_point now() noexcept;
286 static time_t to_time_t (const time_point& __t) noexcept;
287 static time_point from_time_t(time_t __t) noexcept;
290 template <class Duration>
291 using sys_time = time_point<system_clock, Duration>; // C++20
292 using sys_seconds = sys_time<seconds>; // C++20
293 using sys_days = sys_time<days>; // C++20
295 template<class charT, class traits, class Duration> // C++20
296 basic_ostream<charT, traits>&
297 operator<<(basic_ostream<charT, traits>& os, const sys_time<Duration>& tp);
299 template<class charT, class traits> // C++20
300 basic_ostream<charT, traits>&
301 operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);
303 class file_clock // C++20
306 typedef see-below rep;
308 typedef chrono::duration<rep, period> duration;
309 typedef chrono::time_point<file_clock> time_point;
310 static constexpr bool is_steady = false;
312 static time_point now() noexcept;
314 template<class Duration>
315 static sys_time<see-below> to_sys(const file_time<Duration>&);
317 template<class Duration>
318 static file_time<see-below> from_sys(const sys_time<Duration>&);
321 template<class Duration>
322 using file_time = time_point<file_clock, Duration>; // C++20
324 template<class charT, class traits, class Duration> // C++20
325 basic_ostream<charT, traits>&
326 operator<<(basic_ostream<charT, traits>& os, const file_time<Duration>& tp);
331 typedef nanoseconds duration;
332 typedef duration::rep rep;
333 typedef duration::period period;
334 typedef chrono::time_point<steady_clock, duration> time_point;
335 static const bool is_steady = true; // constexpr in C++14
337 static time_point now() noexcept;
340 typedef steady_clock high_resolution_clock;
342 // 25.7.8, local time // C++20
344 template<class Duration>
345 using local_time = time_point<local_t, Duration>;
346 using local_seconds = local_time<seconds>;
347 using local_days = local_time<days>;
349 template<class charT, class traits, class Duration> // C++20
350 basic_ostream<charT, traits>&
351 operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp);
353 // 25.8.2, class last_spec // C++20
356 // 25.8.3, class day // C++20
359 constexpr bool operator==(const day& x, const day& y) noexcept;
360 constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
361 constexpr day operator+(const day& x, const days& y) noexcept;
362 constexpr day operator+(const days& x, const day& y) noexcept;
363 constexpr day operator-(const day& x, const days& y) noexcept;
364 constexpr days operator-(const day& x, const day& y) noexcept;
365 template<class charT, class traits>
366 basic_ostream<charT, traits>&
367 operator<<(basic_ostream<charT, traits>& os, const day& d);
369 // 25.8.4, class month // C++20
371 constexpr bool operator==(const month& x, const month& y) noexcept;
372 constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
374 constexpr month operator+(const month& x, const months& y) noexcept;
375 constexpr month operator+(const months& x, const month& y) noexcept;
376 constexpr month operator-(const month& x, const months& y) noexcept;
377 constexpr months operator-(const month& x, const month& y) noexcept;
378 template<class charT, class traits>
379 basic_ostream<charT, traits>&
380 operator<<(basic_ostream<charT, traits>& os, const month& m);
382 // 25.8.5, class year // C++20
384 constexpr bool operator==(const year& x, const year& y) noexcept;
385 constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
387 constexpr year operator+(const year& x, const years& y) noexcept;
388 constexpr year operator+(const years& x, const year& y) noexcept;
389 constexpr year operator-(const year& x, const years& y) noexcept;
390 constexpr years operator-(const year& x, const year& y) noexcept;
391 template<class charT, class traits>
392 basic_ostream<charT, traits>&
393 operator<<(basic_ostream<charT, traits>& os, const year& y);
395 // 25.8.6, class weekday // C++20
398 constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
399 constexpr weekday operator+(const weekday& x, const days& y) noexcept;
400 constexpr weekday operator+(const days& x, const weekday& y) noexcept;
401 constexpr weekday operator-(const weekday& x, const days& y) noexcept;
402 constexpr days operator-(const weekday& x, const weekday& y) noexcept;
403 template<class charT, class traits>
404 basic_ostream<charT, traits>&
405 operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
407 // 25.8.7, class weekday_indexed // C++20
409 class weekday_indexed;
410 constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
412 template<class charT, class traits>
413 basic_ostream<charT, traits>&
414 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
416 // 25.8.8, class weekday_last // C++20
419 constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
421 template<class charT, class traits>
422 basic_ostream<charT, traits>&
423 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
425 // 25.8.9, class month_day // C++20
428 constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
429 constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
431 template<class charT, class traits>
432 basic_ostream<charT, traits>&
433 operator<<(basic_ostream<charT, traits>& os, const month_day& md);
435 // 25.8.10, class month_day_last // C++20
436 class month_day_last;
438 constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
439 constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
441 template<class charT, class traits>
442 basic_ostream<charT, traits>&
443 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
445 // 25.8.11, class month_weekday // C++20
448 constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
450 template<class charT, class traits>
451 basic_ostream<charT, traits>&
452 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
454 // 25.8.12, class month_weekday_last // C++20
455 class month_weekday_last;
457 constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
459 template<class charT, class traits>
460 basic_ostream<charT, traits>&
461 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
464 // 25.8.13, class year_month // C++20
467 constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
468 constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
470 constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
471 constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
472 constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
473 constexpr months operator-(const year_month& x, const year_month& y) noexcept;
474 constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
475 constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
476 constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
478 template<class charT, class traits>
479 basic_ostream<charT, traits>&
480 operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
482 // 25.8.14, class year_month_day class // C++20
485 constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
486 constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
488 constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
489 constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
490 constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
491 constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
492 constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
493 constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
495 template<class charT, class traits>
496 basic_ostream<charT, traits>&
497 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
499 // 25.8.15, class year_month_day_last // C++20
500 class year_month_day_last;
502 constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
503 constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept;
505 constexpr year_month_day_last
506 operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
507 constexpr year_month_day_last
508 operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
509 constexpr year_month_day_last
510 operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
511 constexpr year_month_day_last
512 operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
513 constexpr year_month_day_last
514 operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
515 constexpr year_month_day_last
516 operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
518 template<class charT, class traits>
519 basic_ostream<charT, traits>&
520 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
522 // 25.8.16, class year_month_weekday // C++20
523 class year_month_weekday;
525 constexpr bool operator==(const year_month_weekday& x,
526 const year_month_weekday& y) noexcept;
528 constexpr year_month_weekday
529 operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
530 constexpr year_month_weekday
531 operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
532 constexpr year_month_weekday
533 operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
534 constexpr year_month_weekday
535 operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
536 constexpr year_month_weekday
537 operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
538 constexpr year_month_weekday
539 operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
541 template<class charT, class traits>
542 basic_ostream<charT, traits>&
543 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
545 // 25.8.17, class year_month_weekday_last // C++20
546 class year_month_weekday_last;
548 constexpr bool operator==(const year_month_weekday_last& x,
549 const year_month_weekday_last& y) noexcept;
550 constexpr year_month_weekday_last
551 operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
552 constexpr year_month_weekday_last
553 operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
554 constexpr year_month_weekday_last
555 operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
556 constexpr year_month_weekday_last
557 operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
558 constexpr year_month_weekday_last
559 operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
560 constexpr year_month_weekday_last
561 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
563 template<class charT, class traits>
564 basic_ostream<charT, traits>&
565 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
567 // 25.8.18, civil calendar conventional syntax operators // C++20
569 operator/(const year& y, const month& m) noexcept;
571 operator/(const year& y, int m) noexcept;
573 operator/(const month& m, const day& d) noexcept;
575 operator/(const month& m, int d) noexcept;
577 operator/(int m, const day& d) noexcept;
579 operator/(const day& d, const month& m) noexcept;
581 operator/(const day& d, int m) noexcept;
582 constexpr month_day_last
583 operator/(const month& m, last_spec) noexcept;
584 constexpr month_day_last
585 operator/(int m, last_spec) noexcept;
586 constexpr month_day_last
587 operator/(last_spec, const month& m) noexcept;
588 constexpr month_day_last
589 operator/(last_spec, int m) noexcept;
590 constexpr month_weekday
591 operator/(const month& m, const weekday_indexed& wdi) noexcept;
592 constexpr month_weekday
593 operator/(int m, const weekday_indexed& wdi) noexcept;
594 constexpr month_weekday
595 operator/(const weekday_indexed& wdi, const month& m) noexcept;
596 constexpr month_weekday
597 operator/(const weekday_indexed& wdi, int m) noexcept;
598 constexpr month_weekday_last
599 operator/(const month& m, const weekday_last& wdl) noexcept;
600 constexpr month_weekday_last
601 operator/(int m, const weekday_last& wdl) noexcept;
602 constexpr month_weekday_last
603 operator/(const weekday_last& wdl, const month& m) noexcept;
604 constexpr month_weekday_last
605 operator/(const weekday_last& wdl, int m) noexcept;
606 constexpr year_month_day
607 operator/(const year_month& ym, const day& d) noexcept;
608 constexpr year_month_day
609 operator/(const year_month& ym, int d) noexcept;
610 constexpr year_month_day
611 operator/(const year& y, const month_day& md) noexcept;
612 constexpr year_month_day
613 operator/(int y, const month_day& md) noexcept;
614 constexpr year_month_day
615 operator/(const month_day& md, const year& y) noexcept;
616 constexpr year_month_day
617 operator/(const month_day& md, int y) noexcept;
618 constexpr year_month_day_last
619 operator/(const year_month& ym, last_spec) noexcept;
620 constexpr year_month_day_last
621 operator/(const year& y, const month_day_last& mdl) noexcept;
622 constexpr year_month_day_last
623 operator/(int y, const month_day_last& mdl) noexcept;
624 constexpr year_month_day_last
625 operator/(const month_day_last& mdl, const year& y) noexcept;
626 constexpr year_month_day_last
627 operator/(const month_day_last& mdl, int y) noexcept;
628 constexpr year_month_weekday
629 operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
630 constexpr year_month_weekday
631 operator/(const year& y, const month_weekday& mwd) noexcept;
632 constexpr year_month_weekday
633 operator/(int y, const month_weekday& mwd) noexcept;
634 constexpr year_month_weekday
635 operator/(const month_weekday& mwd, const year& y) noexcept;
636 constexpr year_month_weekday
637 operator/(const month_weekday& mwd, int y) noexcept;
638 constexpr year_month_weekday_last
639 operator/(const year_month& ym, const weekday_last& wdl) noexcept;
640 constexpr year_month_weekday_last
641 operator/(const year& y, const month_weekday_last& mwdl) noexcept;
642 constexpr year_month_weekday_last
643 operator/(int y, const month_weekday_last& mwdl) noexcept;
644 constexpr year_month_weekday_last
645 operator/(const month_weekday_last& mwdl, const year& y) noexcept;
646 constexpr year_month_weekday_last
647 operator/(const month_weekday_last& mwdl, int y) noexcept;
649 // 26.9, class template hh_mm_ss
650 template <class Duration>
653 bool is_neg; // exposition only
654 chrono::hours h; // exposition only
655 chrono::minutes m; // exposition only
656 chrono::seconds s; // exposition only
657 precision ss; // exposition only
660 static unsigned constexpr fractional_width = see below;
661 using precision = see below;
663 constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
664 constexpr explicit hh_mm_ss(Duration d) noexcept;
666 constexpr bool is_negative() const noexcept;
667 constexpr chrono::hours hours() const noexcept;
668 constexpr chrono::minutes minutes() const noexcept;
669 constexpr chrono::seconds seconds() const noexcept;
670 constexpr precision subseconds() const noexcept;
672 constexpr explicit operator precision() const noexcept;
673 constexpr precision to_duration() const noexcept;
676 template<class charT, class traits, class Duration>
677 basic_ostream<charT, traits>&
678 operator<<(basic_ostream<charT, traits>& os, const hh_mm_ss<Duration>& hms); // C++20
680 // 26.10, 12/24 hour functions
681 constexpr bool is_am(hours const& h) noexcept;
682 constexpr bool is_pm(hours const& h) noexcept;
683 constexpr hours make12(const hours& h) noexcept;
684 constexpr hours make24(const hours& h, bool is_pm) noexcept;
686 // [time.zone.db], time zone database
687 struct tzdb { // C++20
691 class tzdb_list { // C++20
693 tzdb_list(const tzdb_list&) = delete;
694 tzdb_list& operator=(const tzdb_list&) = delete;
696 // unspecified additional constructors
698 class const_iterator;
700 const tzdb& front() const noexcept;
702 const_iterator erase_after(const_iterator p);
704 const_iterator begin() const noexcept;
705 const_iterator end() const noexcept;
707 const_iterator cbegin() const noexcept;
708 const_iterator cend() const noexcept;
711 // [time.zone.db.access], time zone database access
712 const tzdb& get_tzdb(); // C++20
713 tzdb_list& get_tzdb_list(); // C++20
715 // [time.zone.db.remote], remote time zone database support
716 const tzdb& reload_tzdb(); // C++20
717 string remote_version(); // C++20
719 // 25.10.5, class time_zone // C++20
720 enum class choose {earliest, latest};
722 bool operator==(const time_zone& x, const time_zone& y) noexcept;
723 bool operator!=(const time_zone& x, const time_zone& y) noexcept;
724 bool operator<(const time_zone& x, const time_zone& y) noexcept;
725 bool operator>(const time_zone& x, const time_zone& y) noexcept;
726 bool operator<=(const time_zone& x, const time_zone& y) noexcept;
727 bool operator>=(const time_zone& x, const time_zone& y) noexcept;
731 template<class Duration, class charT>
732 struct formatter<chrono::sys_time<Duration>, charT>; // C++20
733 template<class Duration, class charT>
734 struct formatter<chrono::filetime<Duration>, charT>; // C++20
735 template<class Duration, class charT>
736 struct formatter<chrono::local_time<Duration>, charT>; // C++20
737 template<class Rep, class Period, class charT>
738 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
739 template<class charT> struct formatter<chrono::day, charT>; // C++20
740 template<class charT> struct formatter<chrono::month, charT>; // C++20
741 template<class charT> struct formatter<chrono::year, charT>; // C++20
742 template<class charT> struct formatter<chrono::weekday, charT>; // C++20
743 template<class charT> struct formatter<chrono::weekday_indexed, charT>; // C++20
744 template<class charT> struct formatter<chrono::weekday_last, charT>; // C++20
745 template<class charT> struct formatter<chrono::month_day, charT>; // C++20
746 template<class charT> struct formatter<chrono::month_day_last, charT>; // C++20
747 template<class charT> struct formatter<chrono::month_weekday, charT>; // C++20
748 template<class charT> struct formatter<chrono::month_weekday_last, charT>; // C++20
749 template<class charT> struct formatter<chrono::year_month, charT>; // C++20
750 template<class charT> struct formatter<chrono::year_month_day, charT>; // C++20
751 template<class charT> struct formatter<chrono::year_month_day_last, charT>; // C++20
752 template<class charT> struct formatter<chrono::year_month_weekday, charT>; // C++20
753 template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20
754 template<class Rep, class Period, class charT>
755 struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20
759 // calendrical constants
760 inline constexpr last_spec last{}; // C++20
761 inline constexpr chrono::weekday Sunday{0}; // C++20
762 inline constexpr chrono::weekday Monday{1}; // C++20
763 inline constexpr chrono::weekday Tuesday{2}; // C++20
764 inline constexpr chrono::weekday Wednesday{3}; // C++20
765 inline constexpr chrono::weekday Thursday{4}; // C++20
766 inline constexpr chrono::weekday Friday{5}; // C++20
767 inline constexpr chrono::weekday Saturday{6}; // C++20
769 inline constexpr chrono::month January{1}; // C++20
770 inline constexpr chrono::month February{2}; // C++20
771 inline constexpr chrono::month March{3}; // C++20
772 inline constexpr chrono::month April{4}; // C++20
773 inline constexpr chrono::month May{5}; // C++20
774 inline constexpr chrono::month June{6}; // C++20
775 inline constexpr chrono::month July{7}; // C++20
776 inline constexpr chrono::month August{8}; // C++20
777 inline constexpr chrono::month September{9}; // C++20
778 inline constexpr chrono::month October{10}; // C++20
779 inline constexpr chrono::month November{11}; // C++20
780 inline constexpr chrono::month December{12}; // C++20
783 inline namespace literals {
784 inline namespace chrono_literals {
785 constexpr chrono::hours operator ""h(unsigned long long); // C++14
786 constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
787 constexpr chrono::minutes operator ""min(unsigned long long); // C++14
788 constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14
789 constexpr chrono::seconds operator ""s(unsigned long long); // C++14
790 constexpr chrono::duration<unspecified > operator ""s(long double); // C++14
791 constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14
792 constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14
793 constexpr chrono::microseconds operator ""us(unsigned long long); // C++14
794 constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14
795 constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14
796 constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14
797 constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20
798 constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20
807 #include <__assert> // all public C++ headers provide the assertion handler
808 #include <__chrono/calendar.h>
809 #include <__chrono/convert_to_timespec.h>
810 #include <__chrono/convert_to_tm.h>
811 #include <__chrono/day.h>
812 #include <__chrono/duration.h>
813 #include <__chrono/file_clock.h>
814 #include <__chrono/hh_mm_ss.h>
815 #include <__chrono/high_resolution_clock.h>
816 #include <__chrono/literals.h>
817 #include <__chrono/month.h>
818 #include <__chrono/month_weekday.h>
819 #include <__chrono/monthday.h>
820 #include <__chrono/steady_clock.h>
821 #include <__chrono/system_clock.h>
822 #include <__chrono/time_point.h>
823 #include <__chrono/weekday.h>
824 #include <__chrono/year.h>
825 #include <__chrono/year_month.h>
826 #include <__chrono/year_month_day.h>
827 #include <__chrono/year_month_weekday.h>
831 // standard-mandated includes
836 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && _LIBCPP_STD_VER >= 20
837 # include <__chrono/formatter.h>
838 # include <__chrono/ostream.h>
839 # include <__chrono/parser_std_format_spec.h>
840 # include <__chrono/statically_widen.h>
843 #if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
844 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
845 # include <__chrono/tzdb.h>
846 # include <__chrono/tzdb_list.h>
849 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
850 # pragma GCC system_header
853 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
857 # include <forward_list>
861 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20
865 #endif // _LIBCPP_CHRONO