命名空间
变体
操作

std::chrono::tai_clock

来自 cppreference.cn
< cpp‎ | chrono
 
 
 
 
定义于头文件 <chrono>
class tai_clock;
(自 C++20 起)

时钟 std::chrono::tai_clock 是一个 时钟 (Clock),它表示 国际原子时 (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
[静态]
true 如果刻度之间的时间始终恒定,即,即使在某些外部时钟调整的情况下,对 now() 的调用也返回单调递增的值,否则为 false
(公共静态成员常量)

[编辑] 成员函数

[静态]
返回表示当前时间点的 std::chrono::time_point
(公共静态成员函数) [编辑]
[静态]
tai_time 转换为 utc_time
(公共静态成员函数) [编辑]
[静态]
utc_time 转换为 tai_time
(公共静态成员函数) [编辑]