Namespaces
Variants

std::chrono:: gps_clock

From cppreference.net
定义于头文件 <chrono>
class gps_clock ;
(C++20 起)

时钟 std::chrono::gps_clock 是一种 Clock ,用于表示全球定位系统(GPS)时间。它测量自 1980 年 1 月 6 日 00:00:00 UTC 起的时间。

闰秒不会被插入到GPS时间系统中。因此,每当UTC时间插入一个闰秒时,UTC就会比GPS时间再落后一秒。截至2017年12月,UTC比GPS时间落后18秒,这反映了1980年至2017年间插入的18个闰秒。因此,2018-01-01 00:00:00 UTC对应着2018-01-01 00:00:18 GPS时间。GPS时间始终比 TAI 时间固定落后19秒。

gps_clock 满足 Clock 要求。它不满足 TrivialClock 要求,除非实现能够保证 now() 不会抛出异常。

目录

时间点族

定义于命名空间 std::chrono
template < class Duration >
using gps_time = std:: chrono :: time_point < std :: chrono :: gps_clock , Duration > ;
(C++20 起)
using gps_seconds = gps_time < std:: chrono :: seconds > ;
(C++20 起)
gps_time 执行流输出操作
(函数模板)
根据指定格式从流中解析 gps_time
(函数模板)
gps_time 的格式化支持
(类模板特化)

成员类型

成员类型 定义
rep 表示时钟周期数的有符号算术类型
period 表示时钟周期(以秒为单位)的 std::ratio 类型
duration std:: chrono :: duration < rep, period > ,能够表示负时间间隔
time_point std:: chrono :: time_point < std :: chrono :: gps_clock >

成员常量

constexpr bool is_steady
[static]
若时间滴答间隔始终保持恒定(即即使发生外部时钟调整,调用 now() 返回的值仍保持单调递增)则为 true ,否则为 false
(公开静态成员常量)

成员函数

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