std::chrono::time_zone:: to_sys
|
template
<
class
Duration
>
auto
to_sys
(
const
std::
chrono
::
local_time
<
Duration
>
&
tp
)
const
|
(1) | (自 C++20 起) |
|
template
<
class
Duration
>
auto
to_sys
(
const
std::
chrono
::
local_time
<
Duration
>
&
tp,
std::
chrono
::
choose
z
)
const
|
(2) | (自 C++20 起) |
将此时区中的 local_time tp 转换为对应的 sys_time 。
-
若
z
==
std
::
chrono
::
choose
::
earliest
,返回较早的
sys_time。 -
若
z
==
std
::
chrono
::
choose
::
latest
,返回较晚的
sys_time。
time_point
之间不存在的时刻,则这两个
time_point
将相同,并返回该
time_point
。
目录 |
返回值
根据此时区的规则, tp 对应的 UTC 时间。
异常
- std:: chrono :: ambiguous_local_time 若转换存在歧义,
- std:: chrono :: nonexistent_local_time 若 tp 表示不存在的本地时间。
注释
结果的精度至少为 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 。
示例
|
本节内容不完整
原因:缺少示例 |