std::chrono(3cxx)

πŸ•°οΈ NAME

Okay bestie, this is the std::chrono(3cxx) page β€” manual section 3cxx, in the building, serving looks. And what is it? It’s the ISO C++ 2011 namespace for date and time utilities. That’s the whole NAME vibe: std::chrono is the ISO C++ 2011 namespace for date and time utilities. Periodt. πŸ’…


✨ SYNOPSIS ✨

This is the cast list, and every single name below matters. No skipping, no β€œclose enough,” no cap. πŸ’–

Classes

  • class duration β€” chrono::duration represents a distance between two points in time.
  • struct duration_values β€” the description here is literally duration_values. Minimalist. Mysterious. Iconic.
  • class gps_clock β€” no extra description on this page, just the name doing its main character thing.
  • class hh_mm_ss β€” same energy: name only, no little blurb attached.
  • struct steady_clock β€” Monotonic clock.
  • struct system_clock β€” System clock.
  • class tai_clock β€” no extra description here either, just the class name.
  • class time_point β€” chrono::time_point represents a point in time as measured by a clock.
  • struct treat_as_floating_point β€” no description on the page, just the name.
  • class tzdb_list β€” again, name only. The mystery is the branding. πŸ¦‹
  • class utc_clock β€” name only, no description attached.

Typedefs

  • using days = duration< int64_t, ratio< 86400 > > β€” blurb: days.
  • using file_clock = ::std::filesystem::__file_clock β€” no extra description, just this exact alias.
  • template<typename _Duration > using file_time = time_point< file_clock, _Duration > β€” no extra description attached.
  • using gps_seconds = gps_time< seconds > β€” no extra description, just the alias.
  • template<typename _Duration > using gps_time = time_point< gps_clock, _Duration > β€” no blurb here.
  • using high_resolution_clock = system_clock β€” Highest-resolution clock.
  • using hours = duration< int64_t, ratio< 3600 > > β€” blurb: hours.
  • using local_days = local_time< days > β€” no extra description.
  • using local_seconds = local_time< seconds > β€” no extra description.
  • template<typename _Duration > using local_time = time_point< local_t, _Duration > β€” no extra description.
  • using microseconds = duration< int64_t, micro > β€” blurb: microseconds.
  • using milliseconds = duration< int64_t, milli > β€” blurb: milliseconds.
  • using minutes = duration< int64_t, ratio< 60 > > β€” blurb: minutes.
  • using months = duration< int64_t, ratio< 2629746 > > β€” blurb: months.
  • using nanoseconds = duration< int64_t, nano > β€” blurb: nanoseconds.
  • using seconds = duration< int64_t > β€” blurb: seconds.
  • using sys_days = sys_time< days > β€” no extra description.
  • using sys_seconds = sys_time< seconds > β€” no extra description.
  • template<typename _Duration > using sys_time = time_point< system_clock, _Duration > β€” no extra description.
  • using tai_seconds = tai_time< seconds > β€” no extra description.
  • template<typename _Duration > using tai_time = time_point< tai_clock, _Duration > β€” no extra description.
  • using utc_seconds = utc_time< seconds > β€” no extra description.
  • template<typename _Duration > using utc_time = time_point< utc_clock, _Duration > β€” no extra description.
  • using weeks = duration< int64_t, ratio< 604800 > > β€” blurb: weeks.
  • using years = duration< int64_t, ratio< 31556952 > > β€” blurb: years.
  • using zoned_seconds = zoned_time< seconds > β€” no extra description.

Enumerations

  • enum class choose { earliest, latest } β€” that’s the enum, and those are the two enumerators: earliest and latest. No extra blurb on this page. πŸŽ€

πŸ› οΈ Functions

okay bestie, this is the whole squad πŸ’… β€” every free function in the <chrono> posse, with the signatures copied exactly so you can paste them and slay. And yes, almost every from_stream girlie comes with the same two defaulted trailing args (__abbrev=nullptr and __offset=nullptr) β€” we love a consistent aesthetic πŸŽ€


  • __throw_bad_local_time β€” lowkey the thrower-helper: it's void, and it takes a local_time< _Duration > (that's __tp) plus a local_info (that's __i). Signature, verbatim: template<typename _Duration > void __throw_bad_local_time (const local_time< _Duration > &__tp, const local_info &__i)
  • abs (the duration one) β€” the abs overload for a duration< _Rep, _Period >, constexpr, and gated so it only shows up when numeric_limits< _Rep >::is_signed is true πŸ”₯ template<typename _Rep , typename _Period > constexpr enable_if_t< numeric_limits< _Rep >::is_signed, duration< _Rep, _Period > > abs (duration< _Rep, _Period > __d)
  • ceil (the duration one) β€” ceil for a duration, handing you back a _ToDur, constexpr, gated by __enable_if_is_duration< _ToDur > ✨ template<typename _ToDur , typename _Rep , typename _Period > constexpr __enable_if_is_duration< _ToDur > ceil (const duration< _Rep, _Period > &__d)
  • ceil (the time_point one) β€” same ceil energy but for a time_point< _Clock, _Dur >, and you get a time_point< _Clock, _ToDur > back, gated by __is_duration_v< _ToDur > πŸ’« template<typename _ToDur , typename _Clock , typename _Dur > constexpr enable_if_t< __is_duration_v< _ToDur >, time_point< _Clock, _ToDur > > ceil (const time_point< _Clock, _Dur > &__tp)
  • clock_cast β€” Convert a time point to a different clock. Iconic behaviour, and look at that requires clause β€” it's a five-way serve of __detail::__clock_convs<_DestClock, _SourceClock, _Duration>, __detail::__clock_convs_sys<...>, __detail::__clock_convs_utc<...>, __detail::__clock_convs_sys_utc<...>, and __detail::__clock_convs_utc_sys<...>. No cap, she's picky: template<typename _DestClock , typename _SourceClock , typename _Duration > requires __detail::__clock_convs<_DestClock, _SourceClock, _Duration> || __detail::__clock_convs_sys<_DestClock, _SourceClock, _Duration> || __detail::__clock_convs_utc<_DestClock, _SourceClock, _Duration> || __detail::__clock_convs_sys_utc<_DestClock, _SourceClock, _Duration> || __detail::__clock_convs_utc_sys<_DestClock, _SourceClock, _Duration>auto clock_cast (const time_point< _SourceClock, _Duration > &__t)
  • current_zone β€” zero args, one const time_zone * coming your way πŸ¦‹ const time_zone * current_zone ()
  • duration_cast β€” the classic ✨ constexpr, takes const duration< _Rep, _Period > &__d, gives back _ToDur, gated by __enable_if_is_duration< _ToDur >: template<typename _ToDur , typename _Rep , typename _Period > constexpr __enable_if_is_duration< _ToDur > duration_cast (const duration< _Rep, _Period > &__d)
  • floor (the duration one) β€” floor for a duration, constexpr, same __enable_if_is_duration< _ToDur > gate, returns _ToDur 🌸 template<typename _ToDur , typename _Rep , typename _Period > constexpr __enable_if_is_duration< _ToDur > floor (const duration< _Rep, _Period > &__d)
  • floor (the time_point one) β€” floor for a time_point< _Clock, _Dur > β†’ time_point< _Clock, _ToDur >, constexpr, gated by __is_duration_v< _ToDur > 🫢 template<typename _ToDur , typename _Clock , typename _Dur > constexpr enable_if_t< __is_duration_v< _ToDur >, time_point< _Clock, _ToDur > > floor (const time_point< _Clock, _Dur > &__tp)

🌈 the from_stream girlies (there are 14 of them, bestie)

Every single one is a basic_istream< _CharT, _Traits > & and ends with the same two defaulted args: basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr. The _Alloc default is always = allocator<_CharT>. Obsessed with the consistency fr fr 😭

  • from_stream β†’ day template<typename _CharT , typename _Traits , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, day &__d, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ duration (this one also templates on _Rep and _Period) template<typename _CharT , typename _Traits , typename _Rep , typename _Period , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, duration< _Rep, _Period > &__d, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ file_time template<typename _CharT , typename _Traits , typename _Duration , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, file_time< _Duration > &__tp, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ gps_time template<typename _CharT , typename _Traits , typename _Duration , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, gps_time< _Duration > &__tp, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ local_time template<typename _CharT , typename _Traits , typename _Duration , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, local_time< _Duration > &__tp, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ month template<typename _CharT , typename _Traits , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, month &__m, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ month_day template<typename _CharT , typename _Traits , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, month_day &__md, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ sys_time template<typename _CharT , typename _Traits , typename _Duration , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, sys_time< _Duration > &__tp, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ tai_time template<typename _CharT , typename _Traits , typename _Duration , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, tai_time< _Duration > &__tp, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ utc_time template<typename _CharT , typename _Traits , typename _Duration , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, utc_time< _Duration > &__tp, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ weekday template<typename _CharT , typename _Traits , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, weekday &__wd, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ year template<typename _CharT , typename _Traits , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, year &__y, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ year_month template<typename _CharT , typename _Traits , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, year_month &__ym, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)
  • from_stream β†’ year_month_day template<typename _CharT , typename _Traits , typename _Alloc = allocator<_CharT>> basic_istream< _CharT, _Traits > & from_stream (basic_istream< _CharT, _Traits > &__is, const _CharT *__fmt, year_month_day &__ymd, basic_string< _CharT, _Traits, _Alloc > *__abbrev=nullptr, minutes *__offset=nullptr)

  • get_leap_second_info β€” takes a const utc_time< _Duration > &__ut and hands you a leap_second_info πŸ’œ template<typename _Duration > leap_second_info get_leap_second_info (const utc_time< _Duration > &__ut)
  • get_tzdb β€” no args, returns a const tzdb & ⭐ const tzdb & get_tzdb ()
  • get_tzdb_list β€” no args, returns a tzdb_list & 🌟 tzdb_list & get_tzdb_list ()
  • is_am β€” constexpr bool, takes const hours &__h, and it's noexcept (respected) ✨ constexpr bool is_am (const hours &__h) noexcept
  • is_pm β€” same deal, constexpr bool, noexcept, const hours &__h πŸŽ€ constexpr bool is_pm (const hours &__h) noexcept
  • local_time_format β€” templates on _Duration, returns __detail::__local_time_fmt< _Duration >, takes local_time< _Duration > __time plus the defaulted const string *__abbrev=nullptr and const seconds *__offset_sec=nullptr πŸ’« template<typename _Duration > __detail::__local_time_fmt< _Duration > local_time_format (local_time< _Duration > __time, const string *__abbrev=nullptr, const seconds *__offset_sec=nullptr)
  • locate_zone β€” takes string_view __tz_name, gives a const time_zone * πŸ¦‹ const time_zone * locate_zone (string_view __tz_name)
  • make12 β€” constexpr hours, const hours &__h, noexcept 🌸 constexpr hours make12 (const hours &__h) noexcept
  • make24 β€” constexpr hours, takes const hours &__h and a bool __is_pm, noexcept 🌺 constexpr hours make24 (const hours &__h, bool __is_pm) noexcept

πŸ’… the operator<< era

  • operator<< β†’ day template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const day &__d)
  • operator<< β†’ file_time template<typename _CharT , typename _Traits , typename _Duration > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const file_time< _Duration > &__t)
  • operator<< β†’ gps_time template<typename _CharT , typename _Traits , typename _Duration > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const gps_time< _Duration > &__t)
  • operator<< β†’ hh_mm_ss template<typename _CharT , typename _Traits , typename _Duration > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const hh_mm_ss< _Duration > &__hms)
  • operator<< β†’ local_info β€” Writes a local_info object to an ostream in an unspecified format. Unspecified, bestie β€” so don't go building a parser on the exact shape πŸ™ˆ template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const local_info &__li)
  • operator<< β†’ local_time template<typename _CharT , typename _Traits , typename _Duration > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const local_time< _Duration > &__lt)
  • operator<< β†’ month template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const month &__m)
  • operator<< β†’ month_day template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const month_day &__md)
  • operator<< β†’ month_day_last template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const month_day_last &__mdl)
  • operator<< β†’ month_weekday template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const month_weekday &__mwd)
  • operator<< β†’ month_weekday_last template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const month_weekday_last &__mwdl)
  • operator<< β†’ sys_days template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const sys_days &__dp)
  • operator<< β†’ sys_info β€” Writes a sys_info object to an ostream in an unspecified format. Again: unspecified 🫢 template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const sys_info &__i)
  • operator<< β†’ sys_time β€” this one's got a requires clause: (!treat_as_floating_point_v<typename _Duration::rep>) && ratio_less_v<typename _Duration::period, days::period> πŸ”₯ template<typename _CharT , typename _Traits , typename _Duration > requires (!treat_as_floating_point_v<typename _Duration::rep>) && ratio_less_v<typename _Duration::period, days::period>basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const sys_time< _Duration > &__tp)
  • operator<< β†’ tai_time template<typename _CharT , typename _Traits , typename _Duration > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const tai_time< _Duration > &__t)
  • operator<< β†’ utc_time template<typename _CharT , typename _Traits , typename _Duration > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const utc_time< _Duration > &__t)
  • operator<< β†’ weekday template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const weekday &__wd)
  • operator<< β†’ weekday_indexed template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const weekday_indexed &__wdi)
  • operator<< β†’ weekday_last template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const weekday_last &__wdl)
  • operator<< β†’ the next overload β€” and it keeps going, no cap πŸ’€ the signature rolls straight out of this chunk: template<typename _CharT , typename _Traits > basic_ostream< _CharT,

🌸 the operator<< girlies β€” printing every chrono type you own

okay so every single calendar type and duration type has its own stream operator, and they're all templates because of course they are. bestie, these are the ones that make std::cout << work without you crying:

template<typename _CharT , typename _Traits > basic_ostream< _CharT,
    _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
    const year &__y)
template<typename _CharT , typename _Traits > basic_ostream< _CharT,
    _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
    const year_month &__ym)
template<typename _CharT , typename _Traits > basic_ostream< _CharT,
    _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
    const year_month_day &__ymd)
template<typename _CharT , typename _Traits > basic_ostream< _CharT,
    _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
    const year_month_day_last &__ymdl)
template<typename _CharT , typename _Traits > basic_ostream< _CharT,
    _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
    const year_month_weekday &__ymwd)
template<typename _CharT , typename _Traits > basic_ostream< _CharT,
    _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
    const year_month_weekday_last &__ymwdl)

and obviously the timezone one gets its own extra template params, because zoned_time can never just be simple πŸ’€

template<typename _CharT , typename _Traits , typename _Duration ,
    typename _TimeZonePtr > basic_ostream< _CharT, _Traits > &
    operator<< (basic_ostream< _CharT, _Traits > &__os, const
    zoned_time< _Duration, _TimeZonePtr > &__t)

and the duration one is fully qualified with std:: on the stream, which is giving "i was written by a different maintainer" energy but we respect it 🫢

template<typename _CharT , typename _Traits , typename _Rep , typename
    _Period > basic_ostream< _CharT, _Traits > & operator<<
    (std::basic_ostream< _CharT, _Traits > &__os, const duration< _Rep,
    _Period > &__d)

πŸ’… zoned_time equality (yes, == specifically)

one (1) comparison operator lives here and it's the equality one. no <, no <=>, just vibes and bool:

template<typename _Dur1 , typename _TZPtr1 , typename _Dur2 , typename
    _TZPtr2 > bool operator== (const zoned_time< _Dur1, _TZPtr1 > &__x,
    const zoned_time< _Dur2, _TZPtr2 > &__y)

πŸ¦‹ the parse overloads β€” reading strings back into chrono

this whole flock of overloads exists so you can go from text πŸ‘‰ chrono objects, and there are so many of them because C++ said "what if every parameter got its own version". _Parsable is constrained by __detail::__parsable, and some of these hand you back an __abbrev string and/or a minutes& __offset. slay.

template<typename _CharT , __detail::__parsable< _CharT > _Parsable>
    auto parse (const _CharT *__fmt, _Parsable &__tp)
template<typename _CharT , typename _Traits , typename _Alloc , typename
    _StrT  = basic_string<_CharT, _Traits, _Alloc>,
    __detail::__parsable< _CharT, _Traits, _StrT > _Parsable> auto parse
    (const _CharT *__fmt, _Parsable &__tp, basic_string< _CharT,
    _Traits, _Alloc > &__abbrev)
template<typename _CharT , typename _Traits , typename _Alloc , typename
    _StrT  = basic_string<_CharT, _Traits, _Alloc>,
    __detail::__parsable< _CharT, _Traits, _StrT, minutes > _Parsable>
    auto parse (const _CharT *__fmt, _Parsable &__tp, basic_string<
    _CharT, _Traits, _Alloc > &__abbrev, minutes &__offset)

this next one is the offset-only, pointer-flavored, no _Alloc variant β€” note the _StrT default here is just basic_string< _CharT, _Traits>, and the _Traits default is char_traits<_CharT>. copy it exactly, bestie, don't get creative πŸ™ˆ

template<typename _CharT , typename _Traits  = char_traits<_CharT>,
    typename _StrT  = basic_string<_CharT, _Traits>,
    __detail::__parsable< _CharT, _Traits, _StrT, minutes > _Parsable>
    auto parse (const _CharT *__fmt, _Parsable &__tp, minutes &__offset)

and now the exact same four flavors but taking basic_string for __fmt instead of const _CharT *, because consistency is a love language:

template<typename _CharT , typename _Traits , typename _Alloc ,
    __detail::__parsable< _CharT, _Traits > _Parsable> auto parse (const
    basic_string< _CharT, _Traits, _Alloc > &__fmt, _Parsable &__tp)
template<typename _CharT , typename _Traits , typename _Alloc , typename
    _StrT  = basic_string<_CharT, _Traits, _Alloc>,
    __detail::__parsable< _CharT, _Traits, _StrT > _Parsable> auto parse
    (const basic_string< _CharT, _Traits, _Alloc > &__fmt, _Parsable
    &__tp, basic_string< _CharT, _Traits, _Alloc > &__abbrev)
template<typename _CharT , typename _Traits , typename _Alloc , typename
    _StrT  = basic_string<_CharT, _Traits, _Alloc>,
    __detail::__parsable< _CharT, _Traits, _StrT, minutes > _Parsable>
    auto parse (const basic_string< _CharT, _Traits, _Alloc > &__fmt,
    _Parsable &__tp, basic_string< _CharT, _Traits, _Alloc > &__abbrev,
    minutes &__offset)
template<typename _CharT , typename _Traits , typename _Alloc , typename
    _StrT  = basic_string< _CharT, _Traits>, __detail::__parsable<
    _CharT, _Traits, _StrT, minutes > _Parsable> auto parse (const
    basic_string< _CharT, _Traits, _Alloc > &__fmt, _Parsable &__tp,
    minutes &__offset)

πŸŽ€ tzdb glow-ups + rounding + casting

three(3) little legendary functions. reload_tzdb hands you back a const tzdb &, remote_version gives you a string, and then round/time_point_cast do the actual glow-up math ✨

const tzdb & reload_tzdb ()
string remote_version ()

round for a duration β€” note the enable_if_t gate: _ToDur has to be a duration, and its rep must not be treat_as_floating_point. so floating-point reps are literally not invited 🚫

template<typename _ToDur , typename _Rep , typename _Period > constexpr
    enable_if_t< __and_< __is_duration< _ToDur >, __not_<
    treat_as_floating_point< typename _ToDur::rep > > >::value, _ToDur >
    round (const duration< _Rep, _Period > &__d)

same energy for a time_point version, this one gated with __is_duration_v and !treat_as_floating_point_v:

template<typename _ToDur , typename _Clock , typename _Dur > constexpr
    enable_if_t< __is_duration_v< _ToDur > &&!treat_as_floating_point_v<
    typename _ToDur::rep >, time_point< _Clock, _ToDur > > round (const
    time_point< _Clock, _Dur > &__tp)

and time_point_cast β€” classic, __enable_if_t on __is_duration< _ToDur >::value, returns the recast time_point:

template<typename _ToDur , typename _Clock , typename _Dur > constexpr
    __enable_if_t< __is_duration< _ToDur >::value, time_point< _Clock,
    _ToDur > > time_point_cast (const time_point< _Clock, _Dur > &__t)

πŸ‘‘ zoned_time deduction guides

deduction guides my beloved πŸ’– they let you write zoned_time without spelling out the template args like a Victorian.

the plain one drops you into seconds:

zoned_time () -> zoned_time< seconds >

timezone pointer or name, still seconds:

template<typename _TimeZonePtrOrName > zoned_time (_TimeZonePtrOrName
    &&) -> zoned_time< seconds, __time_zone_representation<
    _TimeZonePtrOrName > >

with a local_time, and note the choose=choose::earliest default sitting right there in the guide:

template<typename _TimeZonePtrOrName , typename _Duration > zoned_time
    (_TimeZonePtrOrName &&, local_time< _Duration >,
    choose=choose::earliest) -> zoned_time< common_type_t< _Duration,
    seconds >, __time_zone_representation< _TimeZonePtrOrName > >

with a sys_time β€” no choose here, just vibes:

template<typename _TimeZonePtrOrName , typename _Duration > zoned_time
    (_TimeZonePtrOrName &&, sys_time< _Duration >) -> zoned_time<
    common_type_t< _Duration, seconds >, __time_zone_representation<
    _TimeZonePtrOrName > >

copy-construct-ish from another zoned_time, choose=choose::earliest again:

template<typename _Duration , typename _TimeZonePtrOrName , typename
    _TimeZonePtr2 > zoned_time (_TimeZonePtrOrName &&, zoned_time<
    _Duration, _TimeZonePtr2 >, choose=choose::earliest) -> zoned_time<
    common_type_t< _Duration, seconds >, __time_zone_representation<
    _TimeZonePtrOrName > >

and one lone sys_time guide, no timezone param at all:

template<typename _Duration > zoned_time (sys_time< _Duration >) ->
    zoned_time< common_type_t< _Duration, seconds > >

πŸ”₯ duration math β€” + - * / %

the actual arithmetic, and it's all constexpr because of course it is. the subtraction has an official description, and i quote:

template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 > constexpr common_type< duration< _Rep1,
    _Period1 >, duration< _Rep2, _Period2 > >::type operator- (const
    duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2,
    _Period2 > &__rhs)

The difference between two durations.

scalar-times-duration goes _Rep1 first (const _Rep1 &__s), and uses __common_rep_t both ways:

template<typename _Rep1 , typename _Rep2 , typename _Period >
    constexpr duration< __common_rep_t< _Rep2, _Rep1 >, _Period >
    operator* (const _Rep1 &__s, const duration< _Rep2, _Period >
    &__d)

duration-divided-by-scalar, with that __disable_if_is_duration< _Rep2 > guard so you can't accidentally divide by a duration here:

template<typename _Rep1 , typename _Period , typename _Rep2 >
    constexpr duration< __common_rep_t< _Rep1,
    __disable_if_is_duration< _Rep2 > >, _Period > operator/ (const
    duration< _Rep1, _Period > &__d, const _Rep2 &__s)

duration Γ· duration, and this one returns common_type< _Rep1, _Rep2 >::type β€” like, a plain number, not a duration. iconique:

template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 > constexpr common_type< _Rep1, _Rep2 >::type
    operator/ (const duration< _Rep1, _Period1 > &__lhs, const
    duration< _Rep2, _Period2 > &__rhs)

modulo, same guard as the scalar divide:

template<typename _Rep1 , typename _Period , typename _Rep2 >
    constexpr duration< __common_rep_t< _Rep1,
    __disable_if_is_duration< _Rep2 > >, _Period > operator% (const
    duration< _Rep1, _Period > &__d, const _Rep2 &__s)

and duration % duration, back to a duration result this time:

template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 > constexpr common_type< duration< _Rep1,
    _Period1 >, duration< _Rep2, _Period2 > >::type operator% (const
    duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2,
    _Period2 > &__rhs)

πŸ’€ duration comparisons

five(5) of these bad boys. <, <=, >, >= are all plain constexpr bool, and the <=> is the special one β€” it's requires three_way_comparable<common_type_t<_Rep1, _Rep2>>, so if your reps aren't three-way comparable it simply does not exist for you. no cap.

template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 > constexpr bool operator< (const duration<
    _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 >
    &__rhs)
template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 >
    requires three_way_comparable<common_type_t<_Rep1,
    _Rep2>>constexpr auto operator<=> (const duration< _Rep1,
    _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)"
template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 > constexpr bool operator<= (const duration<
    _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 >
    &__rhs)
template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 > constexpr bool operator> (const duration<
    _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 >
    &__rhs)
template<typename _Rep1 , typename _Period1 , typename _Rep2 ,
    typename _Period2 > constexpr bool operator>= (const duration<
    _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 >
    &__rhs)

🌈 time_point math β€” add a duration, subtract a duration, subtract a time_point

this is the "moving through time" triad and the descriptions are genuinely so clean:

template<typename _Rep1 , typename _Period1 , typename _Clock ,
    typename _Dur2 > constexpr time_point< _Clock, typename
    common_type< duration< _Rep1, _Period1 >, _Dur2 >::type >
    operator+ (const duration< _Rep1, _Period1 > &__lhs, const
    time_point< _Clock, _Dur2 > &__rhs)

Adjust a time point forwards by the given duration.

template<typename _Clock , typename _Dur1 , typename _Rep2 ,
    typename _Period2 > constexpr time_point< _Clock, typename
    common_type< _Dur1, duration< _Rep2, _Period2 > >::type >
    operator- (const time_point< _Clock, _Dur1 > &__lhs, const
    duration< _Rep2, _Period2 > &__rhs)

Adjust a time point backwards by the given duration.

template<typename _Clock , typename _Dur1 , typename _Dur2 >
    constexpr common_type< _Dur1, _Dur2 >::type operator- (const
    time_point< _Clock, _Dur1 > &__lhs, const time_point< _Clock,
    _Dur2 > &__rhs)

The difference between two time points (as a duration)

⭐ time_point comparisons

and the comparison set for time_points, where <=> is constrained by three_way_comparable_with< _Dur1 > _Dur2 (note the > _Dur2> spacing, keep it exactly like that bestie 🫢):

template<typename _Clock , typename _Dur1 ,
    three_way_comparable_with< _Dur1 > _Dur2> constexpr auto
    operator<=> (const time_point< _Clock, _Dur1 > &__lhs, const
    time_point< _Clock, _Dur2 > &__rhs)
template<typename _Clock , typename _Dur1 , typename _Dur2 >
    constexpr bool operator< (const time_point< _Clock, _Dur1 >
    &__lhs, const time_point< _Clock, _Dur2 > &__rhs)
template<typename _Clock , typename _Dur1 , typename _Dur2 >
    constexpr bool operator<= (const time_point< _Clock, _Dur1 >
    &__lhs, const time_point< _Clock, _Dur2 > &__rhs)
template<typename _Clock , typename _Dur1 , typename _Dur2 >
    constexpr bool operator> (const time_point< _Clock, _Dur1 >
    &__lhs, const time_point< _Clock, _Dur2 > &__rhs)
template<typename _Clock , typename _Dur1 , typename _Dur2 >
    constexpr bool operator>= (const time_point< _Clock, _Dur1 >
    &__lhs, const time_point< _Clock, _Dur2 > &__rhs)

πŸ’… VARIABLES πŸ’…

okay bestie, this is the cast list. Every variable, every specialization, every little constexpr moment β€” all here, in the exact order the page gave them. No skips, no edits, no β€œclose enough” energy. πŸ’–

  • __is_time_point_for_v β€” base template declaration: template<typename _Tp , typename _Clock > constexpr bool __is_time_point_for_v. She’s the generic trait girlie ✨
  • __is_time_point_for_v< time_point< _Clock, _Duration >, _Clock > β€” the partial specialization: template<typename _Clock , typename _Duration > constexpr bool __is_time_point_for_v< time_point< _Clock, _Duration >, _Clock >. It’s giving time_point excellence 🫢
  • April β€” constexpr month April. Month constant for April, no cap 🌸
  • August β€” constexpr month August. Month constant for August β˜€οΈ
  • December β€” constexpr month December. Month constant for December πŸŽ€
  • February β€” constexpr month February. Month constant for February πŸ’Œ
  • Friday β€” constexpr weekday Friday. Weekday constant for Friday, and yes she has main character energy πŸ’…
  • is_clock_v β€” base template: template<typename _Tp , typename = void> constexpr bool is_clock_v. Note the exact typename = void spacing, preserved for the culture ✨
  • is_clock_v< file_clock > β€” specialization: template<> constexpr bool is_clock_v< file_clock >. Clock trait moment for file_clock πŸ•°οΈ
  • is_clock_v< gps_clock > β€” specialization: template<> constexpr bool is_clock_v< gps_clock >. Clock trait moment for gps_clock πŸ›°οΈ
  • is_clock_v< steady_clock > β€” specialization: template<> constexpr bool is_clock_v< steady_clock >. Clock trait moment for steady_clock ⏳
  • is_clock_v< system_clock > β€” specialization: template<> constexpr bool is_clock_v< system_clock >. Clock trait moment for system_clock πŸ–₯️
  • is_clock_v< tai_clock > β€” specialization: template<> constexpr bool is_clock_v< tai_clock >. Clock trait moment for tai_clock 🌍
  • is_clock_v< utc_clock > β€” specialization: template<> constexpr bool is_clock_v< utc_clock >. Clock trait moment for utc_clock 🌐
  • January β€” constexpr month January. Month constant for January ❄️
  • July β€” constexpr month July. Month constant for July 🌞
  • June β€” constexpr month June. Month constant for June πŸ“
  • last β€” constexpr last_spec last. The last_spec marker literally named last, and it knows it 😌
  • March β€” constexpr month March. Month constant for March 🌷
  • May β€” constexpr month May. Month constant for May 🌼
  • Monday β€” constexpr weekday Monday. Weekday constant for Monday, lowkey iconic in her own way 🩡
  • November β€” constexpr month November. Month constant for November πŸ‚
  • October β€” constexpr month October. Month constant for October πŸŽƒ
  • Saturday β€” constexpr weekday Saturday. Weekday constant for Saturday, the weekend queen πŸ‘‘
  • September β€” constexpr month September. Month constant for September 🍎
  • Sunday β€” constexpr weekday Sunday. Weekday constant for Sunday, soft-girl rest-day energy 🌸
  • Thursday β€” constexpr weekday Thursday. Weekday constant for Thursday, almost-Friday royalty πŸ’œ
  • treat_as_floating_point_v β€” base template: template<typename _Rep > constexpr bool treat_as_floating_point_v. Trait declaration, serving exactly as written ✨
  • treat_as_floating_point_v< double > β€” specialization: template<> constexpr bool treat_as_floating_point_v< double >. The double moment πŸ’«
  • treat_as_floating_point_v< float > β€” specialization: template<> constexpr bool treat_as_floating_point_v< float >. The float moment 🫧
  • treat_as_floating_point_v< int > β€” specialization: template<> constexpr bool treat_as_floating_point_v< int >. The int moment πŸ”’
  • treat_as_floating_point_v< long > β€” specialization: template<> constexpr bool treat_as_floating_point_v< long >. The long moment πŸ“
  • treat_as_floating_point_v< long double > β€” specialization: template<> constexpr bool treat_as_floating_point_v< long double >. The long double moment 🌈
  • treat_as_floating_point_v< long long > β€” specialization: template<> constexpr bool treat_as_floating_point_v< long long >. The long long moment πŸ’€
  • Tuesday β€” constexpr weekday Tuesday. Weekday constant for Tuesday, underrated but valid πŸ¦‹
  • Wednesday β€” constexpr weekday Wednesday. Weekday constant for Wednesday, the midweek main character πŸŽ€

πŸ•°οΈ DETAILED DESCRIPTION πŸ•°οΈ

The official sentence is: ISO C++ 2011 namespace for date and time utilities. That’s the whole vibe. std::chrono is the ISO C++ 2011 namespace for date and time utilities, and it said what it said. Periodt. πŸ¦‹βœ¨


πŸ‘‘ AUTHOR πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. So yes, the author line is the Doxygen auto-gen flex. Respect the pipeline, bestie 🫢


okay that’s the page, and the footer vibe is: source/version libstdc++, page std::chrono(3cxx), and the date isn’t visible in this chunk β€” so I’m not making one up. Consider this your cute sign-off: πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from