std::chrono::tai_clock
来自cppreference.com
在标头 <chrono> 定义 | ||
class tai_clock; | (C++20 起) | |
时钟 std::chrono::tai_clock
是表示国际原子时 (International Atomic Time, TAI) 的时钟。它度量从 1958 年 1 月 1 日 00:00:00 开始的时间,并且在当天提前 UTC 10 秒(即其纪元 1958-01-01 00:00:00 TAI 是 1957-12-31 23:59:50 UTC)。
不向 TAI 中插入闰秒。因此每次向 UTC 中插入一闰秒,UTC 就多落后 TAI 一秒。迄至 2017 年 12 月,UTC 比 TAI 落后 37 秒,反映了 10 秒的初始差距和 1958 到 2017 年间插入的 27 闰秒。从而 2018-01-01 00:00:00 UTC 等价于 2018-01-01 00:00:37 TAI。
tai_clock
满足时钟(Clock) 的要求。除非实现能保证 now() 不抛异常,否则它不满足平凡时钟(TrivialClock) 的要求。
目录 |
时间点族
定义于命名空间 std::chrono | ||
template<class Duration> using tai_time =std::chrono::time_point<std::chrono::tai_clock, Duration>; | (C++20 起) | |
using tai_seconds = tai_time<std::chrono::seconds>; | (C++20 起) | |
进行 tai_time 上的流输出 (函数模板) | |
按照给定的格式从流分析 tai_time (函数模板) | |
tai_time 的格式化支持 (类模板特化) |
[编辑]成员类型
成员类型 | 定义 |
rep | 表示时钟时长中的计次数的有符号算术类型 |
period | 表示时钟计次周期的 std::ratio 类型,单位为秒 |
duration | std::chrono::duration<rep, period>,能够表示负时长 |
time_point | std::chrono::time_point<std::chrono::tai_clock> |
[编辑]成员常量
constexpr bool is_steady [静态] | 若时间间隔计次始终为常数,即纵使在调整了外部时钟的情况下,调用 now() 的返回值亦单调递增,则为 true;否则为 false (公开静态成员常量) |
[编辑] 成员函数
[静态] | 返回表示当前时间点的 std::chrono::time_point (公开静态成员函数) |
[静态] | 转换 tai_time 为 utc_time (公开静态成员函数) |
[静态] | 从 utc_time 转换到 tai_time (公开静态成员函数) |