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 duration
  • period β€” a std::ratio type representing the tick period of the clock, in seconds
  • duration β€” std::chrono::duration<rep, period>, capable of representing negative durations
  • time_point β€” std::chrono::time_point<std::chrono::system_clock>

πŸ’œ MEMBER CONSTANTS πŸ’œ

  • constexpr bool is_steady [static] β€” true if the time between ticks is always constant, i.e. calls to now() return values that increase monotonically even in case of some external clock adjustment, otherwise false (public static member constant)

πŸ¦‹ MEMBER FUNCTIONS πŸ¦‹

  • now [static] β€” returns a std::chrono::time_point representing the current point in time (public static member function)
  • to_time_t [static] β€” converts a system clock time point to std::time_t (public static member function)
  • from_time_t [static] β€” converts std::time_t to 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