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