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 211template<class charT, class traits, class Rep, class Period> // C++20 212 basic_ostream<charT, traits>& 213 operator<<(basic_ostream<charT, traits>& os, 214 const duration<Rep, Period>& d); 215 216// time_point arithmetic (all constexpr in C++14) 217template <class Clock, class Duration1, class Rep2, class Period2> 218 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> 219 operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); 220template <class Rep1, class Period1, class Clock, class Duration2> 221 time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type> 222 operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs); 223template <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); 226template <class Clock, class Duration1, class Duration2> 227 typename common_type<Duration1, Duration2>::type 228 operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 229 230// time_point comparisons (all constexpr in C++14) 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); 239template <class Clock, class Duration1, class Duration2> 240 bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 241template <class Clock, class Duration1, class Duration2> 242 bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 243 244// time_point_cast (constexpr in C++14) 245 246template <class ToDuration, class Clock, class Duration> 247 time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t); 248 249template <class ToDuration, class Clock, class Duration> 250 constexpr time_point<Clock, ToDuration> 251 floor(const time_point<Clock, Duration>& tp); // C++17 252 253template <class ToDuration, class Clock, class Duration> 254 constexpr time_point<Clock, ToDuration> 255 ceil(const time_point<Clock, Duration>& tp); // C++17 256 257template <class ToDuration, class Clock, class Duration> 258 constexpr time_point<Clock, ToDuration> 259 round(const time_point<Clock, Duration>& tp); // C++17 260 261template <class Rep, class Period> 262 constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17 263 264// Clocks 265 266class system_clock 267{ 268public: 269 typedef microseconds duration; 270 typedef duration::rep rep; 271 typedef duration::period period; 272 typedef chrono::time_point<system_clock> time_point; 273 static const bool is_steady = false; // constexpr in C++14 274 275 static time_point now() noexcept; 276 static time_t to_time_t (const time_point& __t) noexcept; 277 static time_point from_time_t(time_t __t) noexcept; 278}; 279 280template <class Duration> 281 using sys_time = time_point<system_clock, Duration>; // C++20 282using sys_seconds = sys_time<seconds>; // C++20 283using sys_days = sys_time<days>; // C++20 284 285class file_clock // C++20 286{ 287public: 288 typedef see-below rep; 289 typedef nano period; 290 typedef chrono::duration<rep, period> duration; 291 typedef chrono::time_point<file_clock> time_point; 292 static constexpr bool is_steady = false; 293 294 static time_point now() noexcept; 295 296 template<class Duration> 297 static sys_time<see-below> to_sys(const file_time<Duration>&); 298 299 template<class Duration> 300 static file_time<see-below> from_sys(const sys_time<Duration>&); 301}; 302 303template<class Duration> 304 using file_time = time_point<file_clock, Duration>; // C++20 305 306class steady_clock 307{ 308public: 309 typedef nanoseconds duration; 310 typedef duration::rep rep; 311 typedef duration::period period; 312 typedef chrono::time_point<steady_clock, duration> time_point; 313 static const bool is_steady = true; // constexpr in C++14 314 315 static time_point now() noexcept; 316}; 317 318typedef steady_clock high_resolution_clock; 319 320// 25.7.8, local time // C++20 321struct local_t {}; 322template<class Duration> 323 using local_time = time_point<local_t, Duration>; 324using local_seconds = local_time<seconds>; 325using local_days = local_time<days>; 326 327// 25.8.2, class last_spec // C++20 328struct last_spec; 329 330// 25.8.3, class day // C++20 331 332class day; 333constexpr bool operator==(const day& x, const day& y) noexcept; 334constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept; 335constexpr day operator+(const day& x, const days& y) noexcept; 336constexpr day operator+(const days& x, const day& y) noexcept; 337constexpr day operator-(const day& x, const days& y) noexcept; 338constexpr days operator-(const day& x, const day& y) noexcept; 339template<class charT, class traits> 340 basic_ostream<charT, traits>& 341 operator<<(basic_ostream<charT, traits>& os, const day& d); 342 343// 25.8.4, class month // C++20 344class month; 345constexpr bool operator==(const month& x, const month& y) noexcept; 346constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept; 347 348constexpr month operator+(const month& x, const months& y) noexcept; 349constexpr month operator+(const months& x, const month& y) noexcept; 350constexpr month operator-(const month& x, const months& y) noexcept; 351constexpr months operator-(const month& x, const month& y) noexcept; 352template<class charT, class traits> 353 basic_ostream<charT, traits>& 354 operator<<(basic_ostream<charT, traits>& os, const month& m); 355 356// 25.8.5, class year // C++20 357class year; 358constexpr bool operator==(const year& x, const year& y) noexcept; 359constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept; 360 361constexpr year operator+(const year& x, const years& y) noexcept; 362constexpr year operator+(const years& x, const year& y) noexcept; 363constexpr year operator-(const year& x, const years& y) noexcept; 364constexpr years operator-(const year& x, const year& y) noexcept; 365template<class charT, class traits> 366 basic_ostream<charT, traits>& 367 operator<<(basic_ostream<charT, traits>& os, const year& y); 368 369// 25.8.6, class weekday // C++20 370class weekday; 371 372constexpr bool operator==(const weekday& x, const weekday& y) noexcept; 373constexpr bool operator!=(const weekday& x, const weekday& y) noexcept; 374constexpr weekday operator+(const weekday& x, const days& y) noexcept; 375constexpr weekday operator+(const days& x, const weekday& y) noexcept; 376constexpr weekday operator-(const weekday& x, const days& y) noexcept; 377constexpr days operator-(const weekday& x, const weekday& y) noexcept; 378template<class charT, class traits> 379 basic_ostream<charT, traits>& 380 operator<<(basic_ostream<charT, traits>& os, const weekday& wd); 381 382// 25.8.7, class weekday_indexed // C++20 383 384class weekday_indexed; 385constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; 386constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept; 387 388template<class charT, class traits> 389 basic_ostream<charT, traits>& 390 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi); 391 392// 25.8.8, class weekday_last // C++20 393class weekday_last; 394 395constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; 396constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept; 397 398template<class charT, class traits> 399 basic_ostream<charT, traits>& 400 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl); 401 402// 25.8.9, class month_day // C++20 403class month_day; 404 405constexpr bool operator==(const month_day& x, const month_day& y) noexcept; 406constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept; 407 408template<class charT, class traits> 409 basic_ostream<charT, traits>& 410 operator<<(basic_ostream<charT, traits>& os, const month_day& md); 411 412// 25.8.10, class month_day_last // C++20 413class month_day_last; 414 415constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; 416constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept; 417 418template<class charT, class traits> 419 basic_ostream<charT, traits>& 420 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl); 421 422// 25.8.11, class month_weekday // C++20 423class month_weekday; 424 425constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; 426constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept; 427 428template<class charT, class traits> 429 basic_ostream<charT, traits>& 430 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd); 431 432// 25.8.12, class month_weekday_last // C++20 433class month_weekday_last; 434 435constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; 436constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept; 437 438template<class charT, class traits> 439 basic_ostream<charT, traits>& 440 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl); 441 442 443// 25.8.13, class year_month // C++20 444class year_month; 445 446constexpr bool operator==(const year_month& x, const year_month& y) noexcept; 447constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept; 448 449constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; 450constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; 451constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; 452constexpr months operator-(const year_month& x, const year_month& y) noexcept; 453constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; 454constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; 455constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; 456 457template<class charT, class traits> 458 basic_ostream<charT, traits>& 459 operator<<(basic_ostream<charT, traits>& os, const year_month& ym); 460 461// 25.8.14, class year_month_day class // C++20 462year_month_day; 463 464constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; 465constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept; 466 467constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; 468constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; 469constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; 470constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; 471constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; 472constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; 473 474template<class charT, class traits> 475 basic_ostream<charT, traits>& 476 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd); 477 478// 25.8.15, class year_month_day_last // C++20 479class year_month_day_last; 480 481constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept; 482constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept; 483 484constexpr year_month_day_last 485 operator+(const year_month_day_last& ymdl, const months& dm) noexcept; 486constexpr year_month_day_last 487 operator+(const months& dm, const year_month_day_last& ymdl) noexcept; 488constexpr year_month_day_last 489 operator+(const year_month_day_last& ymdl, const years& dy) noexcept; 490constexpr year_month_day_last 491 operator+(const years& dy, const year_month_day_last& ymdl) noexcept; 492constexpr year_month_day_last 493 operator-(const year_month_day_last& ymdl, const months& dm) noexcept; 494constexpr year_month_day_last 495 operator-(const year_month_day_last& ymdl, const years& dy) noexcept; 496 497template<class charT, class traits> 498 basic_ostream<charT, traits>& 499 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl); 500 501// 25.8.16, class year_month_weekday // C++20 502class year_month_weekday; 503 504constexpr bool operator==(const year_month_weekday& x, 505 const year_month_weekday& y) noexcept; 506constexpr bool operator!=(const year_month_weekday& x, 507 const year_month_weekday& y) noexcept; 508 509constexpr year_month_weekday 510 operator+(const year_month_weekday& ymwd, const months& dm) noexcept; 511constexpr year_month_weekday 512 operator+(const months& dm, const year_month_weekday& ymwd) noexcept; 513constexpr year_month_weekday 514 operator+(const year_month_weekday& ymwd, const years& dy) noexcept; 515constexpr year_month_weekday 516 operator+(const years& dy, const year_month_weekday& ymwd) noexcept; 517constexpr year_month_weekday 518 operator-(const year_month_weekday& ymwd, const months& dm) noexcept; 519constexpr year_month_weekday 520 operator-(const year_month_weekday& ymwd, const years& dy) noexcept; 521 522template<class charT, class traits> 523 basic_ostream<charT, traits>& 524 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd); 525 526// 25.8.17, class year_month_weekday_last // C++20 527class year_month_weekday_last; 528 529constexpr bool operator==(const year_month_weekday_last& x, 530 const year_month_weekday_last& y) noexcept; 531constexpr bool operator!=(const year_month_weekday_last& x, 532 const year_month_weekday_last& y) noexcept; 533constexpr year_month_weekday_last 534 operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; 535constexpr year_month_weekday_last 536 operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; 537constexpr year_month_weekday_last 538 operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; 539constexpr year_month_weekday_last 540 operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; 541constexpr year_month_weekday_last 542 operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; 543constexpr year_month_weekday_last 544 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; 545 546template<class charT, class traits> 547 basic_ostream<charT, traits>& 548 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl); 549 550// 25.8.18, civil calendar conventional syntax operators // C++20 551constexpr year_month 552 operator/(const year& y, const month& m) noexcept; 553constexpr year_month 554 operator/(const year& y, int m) noexcept; 555constexpr month_day 556 operator/(const month& m, const day& d) noexcept; 557constexpr month_day 558 operator/(const month& m, int d) noexcept; 559constexpr month_day 560 operator/(int m, const day& d) noexcept; 561constexpr month_day 562 operator/(const day& d, const month& m) noexcept; 563constexpr month_day 564 operator/(const day& d, int m) noexcept; 565constexpr month_day_last 566 operator/(const month& m, last_spec) noexcept; 567constexpr month_day_last 568 operator/(int m, last_spec) noexcept; 569constexpr month_day_last 570 operator/(last_spec, const month& m) noexcept; 571constexpr month_day_last 572 operator/(last_spec, int m) noexcept; 573constexpr month_weekday 574 operator/(const month& m, const weekday_indexed& wdi) noexcept; 575constexpr month_weekday 576 operator/(int m, const weekday_indexed& wdi) noexcept; 577constexpr month_weekday 578 operator/(const weekday_indexed& wdi, const month& m) noexcept; 579constexpr month_weekday 580 operator/(const weekday_indexed& wdi, int m) noexcept; 581constexpr month_weekday_last 582 operator/(const month& m, const weekday_last& wdl) noexcept; 583constexpr month_weekday_last 584 operator/(int m, const weekday_last& wdl) noexcept; 585constexpr month_weekday_last 586 operator/(const weekday_last& wdl, const month& m) noexcept; 587constexpr month_weekday_last 588 operator/(const weekday_last& wdl, int m) noexcept; 589constexpr year_month_day 590 operator/(const year_month& ym, const day& d) noexcept; 591constexpr year_month_day 592 operator/(const year_month& ym, int d) noexcept; 593constexpr year_month_day 594 operator/(const year& y, const month_day& md) noexcept; 595constexpr year_month_day 596 operator/(int y, const month_day& md) noexcept; 597constexpr year_month_day 598 operator/(const month_day& md, const year& y) noexcept; 599constexpr year_month_day 600 operator/(const month_day& md, int y) noexcept; 601constexpr year_month_day_last 602 operator/(const year_month& ym, last_spec) noexcept; 603constexpr year_month_day_last 604 operator/(const year& y, const month_day_last& mdl) noexcept; 605constexpr year_month_day_last 606 operator/(int y, const month_day_last& mdl) noexcept; 607constexpr year_month_day_last 608 operator/(const month_day_last& mdl, const year& y) noexcept; 609constexpr year_month_day_last 610 operator/(const month_day_last& mdl, int y) noexcept; 611constexpr year_month_weekday 612 operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; 613constexpr year_month_weekday 614 operator/(const year& y, const month_weekday& mwd) noexcept; 615constexpr year_month_weekday 616 operator/(int y, const month_weekday& mwd) noexcept; 617constexpr year_month_weekday 618 operator/(const month_weekday& mwd, const year& y) noexcept; 619constexpr year_month_weekday 620 operator/(const month_weekday& mwd, int y) noexcept; 621constexpr year_month_weekday_last 622 operator/(const year_month& ym, const weekday_last& wdl) noexcept; 623constexpr year_month_weekday_last 624 operator/(const year& y, const month_weekday_last& mwdl) noexcept; 625constexpr year_month_weekday_last 626 operator/(int y, const month_weekday_last& mwdl) noexcept; 627constexpr year_month_weekday_last 628 operator/(const month_weekday_last& mwdl, const year& y) noexcept; 629constexpr year_month_weekday_last 630 operator/(const month_weekday_last& mwdl, int y) noexcept; 631 632// 26.9, class template hh_mm_ss 633template <class Duration> 634class hh_mm_ss 635{ 636 bool is_neg; // exposition only 637 chrono::hours h; // exposition only 638 chrono::minutes m; // exposition only 639 chrono::seconds s; // exposition only 640 precision ss; // exposition only 641 642public: 643 static unsigned constexpr fractional_width = see below; 644 using precision = see below; 645 646 constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {} 647 constexpr explicit hh_mm_ss(Duration d) noexcept; 648 649 constexpr bool is_negative() const noexcept; 650 constexpr chrono::hours hours() const noexcept; 651 constexpr chrono::minutes minutes() const noexcept; 652 constexpr chrono::seconds seconds() const noexcept; 653 constexpr precision subseconds() const noexcept; 654 655 constexpr explicit operator precision() const noexcept; 656 constexpr precision to_duration() const noexcept; 657}; 658 659// 26.10, 12/24 hour functions 660constexpr bool is_am(hours const& h) noexcept; 661constexpr bool is_pm(hours const& h) noexcept; 662constexpr hours make12(const hours& h) noexcept; 663constexpr hours make24(const hours& h, bool is_pm) noexcept; 664 665// 25.10.5, class time_zone // C++20 666enum class choose {earliest, latest}; 667class time_zone; 668bool operator==(const time_zone& x, const time_zone& y) noexcept; 669bool operator!=(const time_zone& x, const time_zone& y) noexcept; 670bool operator<(const time_zone& x, const time_zone& y) noexcept; 671bool operator>(const time_zone& x, const time_zone& y) noexcept; 672bool operator<=(const time_zone& x, const time_zone& y) noexcept; 673bool operator>=(const time_zone& x, const time_zone& y) noexcept; 674} // chrono 675 676namespace std { 677 template<class Rep, class Period, class charT> 678 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20 679 template<class charT> struct formatter<chrono::day, charT>; // C++20 680 template<class charT> struct formatter<chrono::month, charT>; // C++20 681 template<class charT> struct formatter<chrono::year, charT>; // C++20 682 template<class charT> struct formatter<chrono::weekday, charT>; // C++20 683 template<class charT> struct formatter<chrono::weekday_indexed, charT>; // C++20 684 template<class charT> struct formatter<chrono::weekday_last, charT>; // C++20 685 template<class charT> struct formatter<chrono::month_day, charT>; // C++20 686 template<class charT> struct formatter<chrono::month_day_last, charT>; // C++20 687 template<class charT> struct formatter<chrono::month_weekday, charT>; // C++20 688 template<class charT> struct formatter<chrono::month_weekday_last, charT>; // C++20 689 template<class charT> struct formatter<chrono::year_month, charT>; // C++20 690 template<class charT> struct formatter<chrono::year_month_day, charT>; // C++20 691 template<class charT> struct formatter<chrono::year_month_day_last, charT>; // C++20 692 template<class charT> struct formatter<chrono::year_month_weekday, charT>; // C++20 693 template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20 694} // namespace std 695 696namespace chrono { 697// calendrical constants 698inline constexpr last_spec last{}; // C++20 699inline constexpr chrono::weekday Sunday{0}; // C++20 700inline constexpr chrono::weekday Monday{1}; // C++20 701inline constexpr chrono::weekday Tuesday{2}; // C++20 702inline constexpr chrono::weekday Wednesday{3}; // C++20 703inline constexpr chrono::weekday Thursday{4}; // C++20 704inline constexpr chrono::weekday Friday{5}; // C++20 705inline constexpr chrono::weekday Saturday{6}; // C++20 706 707inline constexpr chrono::month January{1}; // C++20 708inline constexpr chrono::month February{2}; // C++20 709inline constexpr chrono::month March{3}; // C++20 710inline constexpr chrono::month April{4}; // C++20 711inline constexpr chrono::month May{5}; // C++20 712inline constexpr chrono::month June{6}; // C++20 713inline constexpr chrono::month July{7}; // C++20 714inline constexpr chrono::month August{8}; // C++20 715inline constexpr chrono::month September{9}; // C++20 716inline constexpr chrono::month October{10}; // C++20 717inline constexpr chrono::month November{11}; // C++20 718inline constexpr chrono::month December{12}; // C++20 719} // chrono 720 721inline namespace literals { 722 inline namespace chrono_literals { 723constexpr chrono::hours operator ""h(unsigned long long); // C++14 724constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14 725constexpr chrono::minutes operator ""min(unsigned long long); // C++14 726constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14 727constexpr chrono::seconds operator ""s(unsigned long long); // C++14 728constexpr chrono::duration<unspecified > operator ""s(long double); // C++14 729constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14 730constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14 731constexpr chrono::microseconds operator ""us(unsigned long long); // C++14 732constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14 733constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14 734constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14 735constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20 736constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20 737} // chrono_literals 738} // literals 739 740} // std 741*/ 742 743#include <__assert> // all public C++ headers provide the assertion handler 744#include <__chrono/calendar.h> 745#include <__chrono/convert_to_timespec.h> 746#include <__chrono/convert_to_tm.h> 747#include <__chrono/day.h> 748#include <__chrono/duration.h> 749#include <__chrono/file_clock.h> 750#include <__chrono/hh_mm_ss.h> 751#include <__chrono/high_resolution_clock.h> 752#include <__chrono/literals.h> 753#include <__chrono/month.h> 754#include <__chrono/month_weekday.h> 755#include <__chrono/monthday.h> 756#include <__chrono/steady_clock.h> 757#include <__chrono/system_clock.h> 758#include <__chrono/time_point.h> 759#include <__chrono/weekday.h> 760#include <__chrono/year.h> 761#include <__chrono/year_month.h> 762#include <__chrono/year_month_day.h> 763#include <__chrono/year_month_weekday.h> 764#include <__config> 765#include <version> 766 767// standard-mandated includes 768 769// [time.syn] 770#include <compare> 771 772#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) && _LIBCPP_STD_VER > 17 773# include <__chrono/formatter.h> 774# include <__chrono/ostream.h> 775# include <__chrono/parser_std_format_spec.h> 776# include <__chrono/statically_widen.h> 777#endif 778 779 780#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 781# pragma GCC system_header 782#endif 783 784#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 785# include <concepts> 786#endif 787 788#endif // _LIBCPP_CHRONO 789