std::chrono::system_clock(3)
β¨ std::chrono::system_clock β¨
Bestie, welcome to the C++ Standard Library manual page for std::chrono::system_clock π this one's all about the clock that literally runs the world (or at least your computer's whole concept of "now").
πΈ SYNOPSIS πΈ
Defined in header <chrono>:
class system_clock; (since C++11)
π DESCRIPTION π
So class std::chrono::system_clock represents the system-wide real time wall clock. Periodt.
It may not be monotonic β and no cap, on most systems the system time can be adjusted at literally any moment π. It is the only C++ clock that has the ability to map its time points to C-style time. Iconic behavior tbh.
std::chrono::system_clock meets the requirements of TrivialClock.
The epoch of system_clock is unspecified, but most implementations use Unix Time (i.e., time since 00:00:00 Coordinated Universal Time (UTC), (until C++20) Thursday, 1 January 1970, not counting leap seconds). system_clock measures Unix Time (i.e., time since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap (since C++20) seconds).
π MEMBER TYPES π
repβ signed arithmetic type representing the number of ticks in the clock's durationperiodβ astd::ratiotype representing the tick period of the clock, in secondsdurationβstd::chrono::duration<rep, period>, capable of representing negative durationstime_pointβstd::chrono::time_point<std::chrono::system_clock>
π MEMBER CONSTANTS π
constexpr bool is_steady[static] βtrueif the time between ticks is always constant, i.e. calls tonow()return values that increase monotonically even in case of some external clock adjustment, otherwisefalse(public static member constant)
π¦ MEMBER FUNCTIONS π¦
now[static] β returns astd::chrono::time_pointrepresenting the current point in time (public static member function)to_time_t[static] β converts a system clock time point tostd::time_t(public static member function)from_time_t[static] β convertsstd::time_tto a system clock time point (public static member function)
π NOTES π
The system_clock's time value can be internally adjusted at any time by the operating system β for example due to NTP synchronization or the user changing the system's clock π. Daylight Saving Time and time zone changes, however, do not affect it since it is based on the UTC time-zone. Slay.
π SEE ALSO π
steady_clock(C++11) β monotonic clock that will never be adjusted (class)high_resolution_clock(C++11) β the clock with the shortest tick period available (class)
Source: http://cppreference.com β¨ Date: 2024.06.10 π and that's the whole std::chrono::system_clock(3) manual page, bestie β go forth and measure some wall-clock time, you absolute icon π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms