在线文档教程
C++
应用 | Utilities

std::chrono::system_clock

STD::时间::系统[医]钟

Defined in header
class system_clock;(since C++11)

std::chrono::system_clock表示系统范围内的实时挂钟。

它可能不是单调的:在大多数系统中,系统时间可以随时调整。它是唯一一个C++时钟,它能够将它的时间点映射到C样式的时间,因此,将被显示。

std::chrono::system_clock满足…的要求TrivialClock...

成员类型

Member typeDefinition
repsigned arithmetic type representing the number of ticks in the clock's duration 带符号的算术类型,表示时钟持续时间中的滴答数
perioda std::ratio type representing the tick period of the clock, in seconds 一个std::ratio类型,表示时钟的滴答周期,以秒为单位
durationstd::chrono::duration<rep, period>, capable of representing negative durations Std::chrono::duration<滴答数, 滴答周期>,能够表示负的持续时间
time_pointstd::chrono::time_point<std::chrono::system_clock>

成员常数

constexpr bool is_steady statictrue 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 (public static member constant)

成员函数

now staticreturns a std::chrono::time_point representing the current point in time (public static member function)
to_time_t staticconverts a system clock time point to std::time_t (public static member function)
from_time_t staticconverts std::time_t to a system clock time point (public static member function)

另见

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)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/chrono/system[医]钟