std::chrono::system_clock

定义于头文件 <chrono>
class system_clock;
(C++11 起)

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

它可以不单调:大多数系统上,系统时间可以在任何时候被调节。它是唯一有能力映射其时间点到 C 风格时间,从而能显示的 C++ 时钟。

std::chrono::system_clock 满足平凡时钟 (TrivialClock) 的要求。

不指定 system_clock 的纪元,但多数实现使用 Unix 时间(即从协调世界时( UTC ) 1970 年 1 月 1 日星期四 00:00:00 开始的时间,不计闰秒)。

目录

成员类型

成员类型 定义
rep 表示时钟时长中计次数的有符号算术类型
period 表示时钟计次周期的 std::ratio 类型,单位为秒
duration std::chrono::duration<rep, period> ,足以表示负时长
time_point std::chrono::time_point<std::chrono::system_clock>

成员常量

constexpr bool is_steady
[静态]
若时间间隔计次始终为常量,即纵使在外部时钟调整的情况下,调用 now() 的返回值亦单调递增,则为 true ,否则为 false
(公开静态成员常量)

成员函数

[静态]
返回表示时间中当前点的 std::chrono::time_point
(公开静态成员函数)
[静态]
转换系统时钟时间点为 std::time_t
(公开静态成员函数)
[静态]
转换 std::time_t 到系统时钟时间点
(公开静态成员函数)

参阅

(C++11)
决不调整的单调时钟
(类)
拥有最短可用计次周期的时间
(类)

版本历史

  • (当前 | 先前 2017年9月22日 (五) 07:30Fruderica讨论 | 贡献 . . (1,940字节) (+3). . (撤销)
  • 当前 | 先前 2017年9月22日 (五) 07:25Fruderica讨论 | 贡献. . (1,937字节) (-1,036). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 08:21P12bot讨论 | 贡献 . . (2,973字节) (-187). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 15:58P12bot讨论 | 贡献 . . (3,160字节) (+249). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 10:51P12讨论 | 贡献 . . (2,911字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 07:00TranslationBot讨论 | 贡献. . (2,911字节) (-86). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 14:15P12讨论 | 贡献 . . (2,997字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 13:00TranslationBot讨论 | 贡献. . (2,997字节) (+2,997). . (Translated from the English version using Google Translate)