std::chrono(3)
π std::chrono(3) π
okay bestie, welcome to std::chrono(3) from the Library Functions Manual. this whole page is literally the ISO C++ 2011 namespace for date and time utilities. no cap. it's part 1, so we're just getting started. π
β¨ NAME β¨
std::chrono β ISO C++ 2011 namespace for date and time utilities.
π SYNOPSIS π
π Classes
class durationβchrono::durationrepresents a distance between two points in time. it's giving "how long though?" energy. πstruct duration_valuesβduration_values. that's the whole description, bestie. short and iconic.class gps_clockβ no extra description in the original, just the class name. it's mysterious like that. π¦class hh_mm_ssβ also no description attached. just vibes. β¨struct steady_clockβMonotonic clock.periodt.struct system_clockβSystem clock.yep.class tai_clockβ no description. it's just there, being a clock. π°οΈclass time_pointβchrono::time_pointrepresents a point in time as measured by a clock. so it's a timestamp with main character energy. πstruct treat_as_floating_pointβ no description, just the struct name. ok.class tzdb_listβ no description. tzdb said what it said. πclass utc_clockβ no description. utc clock is utc clocking. π
πΈ Typedefs
using daysβdays. that's it. that's the typedef. πusing file_clockβ no description attached.template<typename _Duration> using file_timeβ no description attached.using gps_secondsβ no description attached.template<typename _Duration> using gps_timeβ no description attached.using high_resolution_clockβHighest-resolution clock.periodt.using hoursβhours. iconic.using local_daysβ no description attached.using local_secondsβ no description attached.template<typename _Duration> using local_timeβ no description attached.using microsecondsβmicroseconds. tiny but mighty. π§using millisecondsβmilliseconds. slay.using minutesβminutes. yes bestie.using monthsβmonths. calendar energy. πusing nanosecondsβnanoseconds. so smol. πusing secondsβseconds. the classic.using sys_daysβ no description attached.using sys_secondsβ no description attached.template<typename _Duration> using sys_timeβ no description attached.using tai_secondsβ no description attached.template<typename _Duration> using tai_timeβ no description attached.using utc_secondsβ no description attached.template<typename _Duration> using utc_timeβ no description attached.using weeksβweeks. that's the typedef. ποΈusing yearsβyears. periodt. πusing zoned_secondsβ no description attached.
π Enumerations
enum class choose { earliest, latest }β no description attached, just the enum and its two values. periodt.
β¨ Functions β¨
okay bestie, here's the full function lineup β every single one, no skips. π
absβ¨
template<typename _Rep, typename _Period> constexpr enable_if_t<
numeric_limits< _Rep >::is_signed, duration< _Rep, _Period > > abs
(duration< _Rep, _Period > __d)
ceil(forduration) π¦
template<typename _ToDur, typename _Rep, typename _Period> constexpr
__enable_if_is_duration< _ToDur > ceil (const duration< _Rep,
_Period > &__d)
ceil(fortime_point) π¦
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π₯
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)"
Convert a time point to a different clock. it's giving time zone traveler energy βοΈ
current_zoneπ
const time_zone * current_zone ()
duration_castπ
template<typename _ToDur, typename _Rep, typename _Period> constexpr
__enable_if_is_duration< _ToDur > duration_cast (const duration<
_Rep, _Period > &__d)
floor(forduration) β
template<typename _ToDur, typename _Rep, typename _Period> constexpr
__enable_if_is_duration< _ToDur > floor (const duration< _Rep,
_Period > &__d)
floor(fortime_point) β
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)
from_stream(forday) π
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(forduration) π
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(forfile_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(forgps_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(forlocal_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(formonth) π
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(formonth_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(forsys_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(fortai_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(forutc_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(forweekday) π
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(foryear) π
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(foryear_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(foryear_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π
template<typename _Duration> leap_second_info get_leap_second_info
(const utc_time< _Duration > &__ut)
get_tzdbπ
const tzdb & get_tzdb ()
get_tzdb_listπ
tzdb_list & get_tzdb_list ()
is_amπ
constexpr bool is_am (const hours &__h) noexcept
True if a chrono::hours value represents a time before midday. morning vibes fr fr βοΈ
is_pmπ
constexpr bool is_pm (const hours &__h) noexcept
True if a chrono::hours value represents a time after midday. afternoon energy periodt π
local_time_formatπΏ
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πΏ
const time_zone * locate_zone (string_view __tz_name)
make12π
constexpr hours make12 (const hours &__h) noexcept
Convert a 24-hour time into a 12-hour time. clock math slay π
make24π
constexpr hours make24 (const hours &__h, bool __is_pm) noexcept
Convert a 12-hour time and p.m. flag into a 24-hour time. the way it just works π°οΈ
operator<<(forday) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const day &__d)
operator<<(forfile_time) π
template<typename _CharT, typename _Traits, typename _Duration>
basic_ostream< _CharT, _Traits > & operator<< (basic_ostream<
_CharT, _Traits > &__os, const file_time< _Duration > &__t)
operator<<(forgps_time) π
template<typename _CharT, typename _Traits, typename _Duration>
basic_ostream< _CharT, _Traits > & operator<< (basic_ostream<
_CharT, _Traits > &__os, const gps_time< _Duration > &__t)
operator<<(forhh_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<<(forlocal_info) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const local_info &__li)
Writes a local_info object to an ostream in an unspecified format. it's giving mysterious β¨
operator<<(forlocal_time) π
template<typename _CharT, typename _Traits, typename _Duration>
requires requires(const sys_time<_Duration>& __st) { __os << __st;
}basic_ostream< _CharT, _Traits > & operator<< (basic_ostream<
_CharT, _Traits > &__os, const local_time< _Duration > &__lt)"
operator<<(formonth) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const month &__m)
operator<<(formonth_day) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const month_day &__md)
operator<<(formonth_day_last) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const month_day_last &__mdl)
operator<<(formonth_weekday) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const month_weekday &__mwd)
operator<<(formonth_weekday_last) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const month_weekday_last &__mwdl)
operator<<(forsys_days) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const sys_days &__dp)
operator<<(forsys_info) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const sys_info &__i)
Writes a sys_info object to an ostream in an unspecified format. also mysterious, no cap π«Ά
operator<<(forsys_time) π
template<typename _CharT, typename _Traits, typename _Duration>
basic_ostream< _CharT, _Traits > & operator<< (basic_ostream<
_CharT, _Traits > &__os, const sys_time< _Duration > &__tp)
operator<<(fortai_time) π
template<typename _CharT, typename _Traits, typename _Duration>
basic_ostream< _CharT, _Traits > & operator<< (basic_ostream<
_CharT, _Traits > &__os, const tai_time< _Duration > &__t)
operator<<(forutc_time) π
template<typename _CharT, typename _Traits, typename _Duration>
basic_ostream< _CharT, _Traits > & operator<< (basic_ostream<
_CharT, _Traits > &__os, const utc_time< _Duration > &__t)
operator<<(forweekday) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const weekday &__wd)
operator<<(forweekday_indexed) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const weekday_indexed &__wdi)
operator<<(forweekday_last) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
const weekday_last &__wdl)
operator<<(continuing...) π
template<typename _CharT, typename _Traits> basic_ostream< _CharT,
_Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os,
Okay so, still deep in the SYNOPSIS, still thriving. π This chunk is all the free functions and operators β the ones that make the chrono calendar types actually do stuff. Strap in bestie, we're going declaration by declaration and I'm not skipping a single one. β¨
π
first, the tail end of an operator<< (the year one)
This is literally just the last line of a declaration that started back in the previous part, so here it is, exactly as it landed:
const year &__y)
Iconic. Moving on. π«Ά
πΈ operator<< for every calendar type you own
Every one of these is the same energy: take a basic_ostream< _CharT, _Traits > &__os, take your date object, return the stream so you can chain. That's it. That's the whole vibe.
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)
So like β year_month, year_month_day, year_month_day_last, year_month_weekday, year_month_weekday_last. All the calendar combos get to be printed. No cap. π
And then the two spicy ones β one for zoned_time (which carries its own _Duration and _TimeZonePtr), and one that takes a std::basic_ostream explicitly for a plain old duration:
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)
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)
Note that the duration one is spelled with the full std::basic_ostream and the others aren't β that's just how it's written, don't come for me, I'm reporting the facts. π
β¨ operator== for zoned_time, and it's cross-type
Two different zoned_times, each with their own _Dur and _TZPtr, and you can still ask if they're equal. Main character behaviour honestly.
template<typename _Dur1, typename _TZPtr1, typename _Dur2, typename
_TZPtr2> bool operator== (const zoned_time< _Dur1, _TZPtr1 > &__x,
const zoned_time< _Dur2, _TZPtr2 > &__y)
π parse β the overload family reunion
Okay so this is the part where it's giving forty identical twins. π There's a whole swarm of parse overloads, and the way to read them is: does it take a const _CharT *__fmt or a const basic_string<...> &__fmt? Does it also give you back an __abbrev string? Does it also give you a minutes &__offset? That's it. Three little toggles, and boom, you've decoded the whole family. π
The const _CharT *__fmt crew, plainest first:
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)
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)
See what I mean? __abbrev? optional. __offset? optional. And heads up, the fourth one there is the one with typename _Traits = char_traits<_CharT> as a default β that's the one that stands out from the crowd. β
Now the basic_string version, same family, different first argument:
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)
Notice the _StrT default is spelled two different ways across these β basic_string<_CharT, _Traits, _Alloc> in most, and basic_string<_CharT, _Traits> in that last one. Yes, I noticed. Yes, I'm telling you. Copy it exactly or the compiler will simply not. π
π¦ tzdb reload & remote version β two little free functions
const tzdb & reload_tzdb ()
string remote_version ()
reload_tzdb () hands you back a const tzdb &. remote_version () hands you back a plain string. Short, sweet, no template drama. π
π₯ round and time_point_cast β the enable_if girlies
These two are doing the whole SFINAE thing where they only even exist if your target type makes sense. Don't fight it, just read the constraints:
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)
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)
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)
The duration round uses the old-school __and_ / __is_duration / __not_ / treat_as_floating_point combo. The time_point round uses the newer __is_duration_v / treat_as_floating_point_v variable-template spelling. And time_point_cast uses __enable_if_t with a ::value. Three different dialects of the same idea, all valid, all here. π«Ά
π zoned_time deduction guides
This is the deduction guide section and honestly it's serving convenience. You get a default guide to zoned_time< seconds >, guides that sniff out the time zone representation from whatever _TimeZonePtrOrName you passed, guides that fold in a local_time< _Duration > or a sys_time< _Duration >, and a guide that takes another zoned_time and converts it. Several of them default choose to choose::earliest. β
zoned_time () -> zoned_time< seconds >
template<typename _TimeZonePtrOrName> zoned_time (_TimeZonePtrOrName &&)
-> zoned_time< seconds, __time_zone_representation<
_TimeZonePtrOrName > >
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 > >
template<typename _TimeZonePtrOrName, typename _Duration> zoned_time
(_TimeZonePtrOrName &&, sys_time< _Duration >) -> zoned_time<
common_type_t< _Duration, seconds >, __time_zone_representation<
_TimeZonePtrOrName > >
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 > >
template<typename _Duration> zoned_time (sys_time< _Duration >) ->
zoned_time< common_type_t< _Duration, seconds > >
Every single one that has a _Duration collapses it with common_type_t< _Duration, seconds >. That's the move. π
And yeah, the last one β zoned_time (sys_time< _Duration >) β doesn't have a choose parameter at all, and it doesn't take a zone name either, so don't @ me. π
π time_point comparisons β the finale of this part
Last block, and it's the full comparison set for time_point. You've got the three-way operator<=> (constrained with three_way_comparable_with< _Dur1 > _Dur2, returning constexpr auto), plus the four classics: <, <=, >, >=. All constexpr, all taking const time_point< _Clock, _Dur1 > &__lhs and const time_point< _Clock, _Dur2 > &__rhs. Note that _Dur1 and _Dur2 are allowed to differ. Yes bestie, cross-duration comparison, we love to see it. π
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)
And that's where this chunk of the SYNOPSIS stops. β¨ The declarations keep going, so stay tuned, we're literally not done. π§
β¨ Variables β¨
okay bestie, here's the whole vibe check of variables in std::chrono β every single one, no skips π
constexpr month Aprilconstexpr month Augustconstexpr month Decemberconstexpr month Februaryconstexpr weekday Fridaytemplate<typename _Tp> constexpr bool is_clock_vtemplate<typename _Tp> constexpr bool is_clock_v< _Tp >template<> constexpr bool is_clock_v< file_clock >template<> constexpr bool is_clock_v< gps_clock >template<> constexpr bool is_clock_v< steady_clock >template<> constexpr bool is_clock_v< system_clock >template<> constexpr bool is_clock_v< tai_clock >template<> constexpr bool is_clock_v< utc_clock >constexpr month Januaryconstexpr month Julyconstexpr month Juneconstexpr last_spec lastconstexpr month Marchconstexpr month Mayconstexpr weekday Mondayconstexpr month Novemberconstexpr month Octoberconstexpr weekday Saturdayconstexpr month Septemberconstexpr weekday Sundayconstexpr weekday Thursdaytemplate<typename _Rep> constexpr bool treat_as_floating_point_vtemplate<> constexpr bool treat_as_floating_point_v< double >template<> constexpr bool treat_as_floating_point_v< float >template<> constexpr bool treat_as_floating_point_v< int >template<> constexpr bool treat_as_floating_point_v< long >template<> constexpr bool treat_as_floating_point_v< long double >template<> constexpr bool treat_as_floating_point_v< long long >constexpr weekday Tuesdayconstexpr weekday Wednesday
and here come the functions, all of them, no skips π
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)
bestie, this one gives you the difference between two durations π
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)
and this one is the sum of two durations, slay β¨
template<typename _Rep1, typename _Rep2, typename _Period> constexpr duration< __common_rep_t< _Rep2, _Rep1 >, _Period > operator* (const _Rep1 &__s, const duration< _Rep2, _Period > &__d)
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)
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)
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)
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)
template<typename _Rep1, typename _Period, typename _Rep2> constexpr duration< __common_rep_t< _Rep1, _Rep2 >, _Period > operator* (const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
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 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)
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 _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)
moves a time point forwards by the given duration, periodt π°οΈ
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)
moves a time point backwards by the given duration, no cap π
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)
gives you the difference between two time points (as a duration), iconic π
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)
same energy: moves a time point forwards by the given duration, periodt π
πΈ Detailed Description πΈ
ISO C++ 2011 namespace for date and time utilities. that's the whole glow-up, bestie β¨
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. no cap, the robots did this one π€
and that's a wrap! this page is from libstdc++ and it's the std::chrono(3) manual. the date isn't in this footer, but you know it's giving libstdc++ energy π β¨
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms