std::chrono::time_zone::to_sys
提供: cppreference.com
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
に変換します。
1) 変換が曖昧な場合、または
tp
が存在しない時間を表している場合、例外を投げます。2)
z
の値に従って曖昧性を解決します。
- z == std::chrono::choose::earliest であれば、早い方の
sys_time
を返します。 - z == std::chrono::choose::latest であれば、遅い方の
sys_time
を返します。
tp
が2つの UTC time_point
間の存在しない時間を表す場合、それら2つの time_point
は同じであり、その time_point
が返されます。[編集] 戻り値
このタイムゾーンのルールに従った tp
と同等の UTC。
[編集] 例外
1) 変換が曖昧な場合は std::chrono::ambiguous_local_time を投げます。
tp
が存在しない時間の場合は std::chrono::nonexistent_local_time を投げます。[編集] ノート
結果の精度は少なくとも std::chrono::seconds
で、引数がより高い精度を持っていれば、より高くなります。
曖昧な時間や存在しない時間は、タイムゾーンの移行 (夏時間など) の結果として発生する場合があります。 例えば "America/New_York" のタイムゾーンでは、 2016-03-13 02:30:00 が存在しませんし、 2016-11-06 01:30:00 に対応する UTC の時間は 2016-11-06 05:30:00 UTC と 2016-11-06 06:30:00 UTC の2つがあります。