std::chrono::time_zone::to_sys
| 时间点 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 时长 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 时钟 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 当天时刻 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 日历 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 时区 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chrono
I/O
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++20)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| C 风格日期和时间 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 成员函数 | ||||
|
time_zone::to_sys
|
||||
| 非成员函数 | ||||
|
template<
class
Duration >
auto
to_sys(const
std::chrono::local_time<Duration>&
tp)
const |
(C++20 起) | |
|
template<
class
Duration >
auto
to_sys(const
std::chrono::local_time<Duration>&
tp, std::chrono::choose
z)
const |
(C++20 起) | |
转换此时区中的 local_time tp 为对应的 sys_time 。
tp
表示不存在的时间则抛出异常。z 的值解决歧义:
- 若 z
== std::chrono::choose::earliest
,则返回较早的
sys_time。 - 若 z
== std::chrono::choose::latest
,则返回较晚的
sys_time。
tp 表示二个 UTC
time_point 间不存在的时间,则二个 time_point 将相同,并将返回该
time_point 。返回值
按照此时区规则的 tp 的 UTC 等价版本。
异常
tp 表示不存在的时间则抛出 std::chrono::nonexistent_local_time 。注意
结果的精度至少为 std::chrono::seconds ,而且若参数有更精细的精度则将更精细。
歧义和不存在的本地时间能作为时区转变(例如夏时令)的结果出现。例如, "2016-03-13 02:30:00" 不存在于 "America/New_York" 时区,而该时区中的 "2016-11-06 01:30:00" 能对应二个 UTC 时间点: 2016-11-06 05:30:00 UTC 和 2016-11-06 06:30:00 UTC 。