std::chrono::time_zone::to_sys

From cppreference.com
< cpp‎ | chrono‎ | time zone
Date and time library
Time point
(C++11)
(C++20)
Duration
(C++11)
Clocks
(C++11)
(C++11)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Time of day
(C++20)(C++20)
(C++20)(C++20)
(C++20)

Calendar
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
Time zone
(C++20)
(C++20)
(C++20) (C++20) (C++20) (C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
chrono I/O
(C++20)
C-style date and time
template < class Duration >

auto to_sys( const std::chrono::local_time <Duration> & tp ) const

- > std::chrono::sys_time < std::common_type_t <Duration, std::chrono::seconds >> ;
(1) (since C++20)
template < class Duration >

auto to_sys( const std::chrono::local_time <Duration> & tp, std::chrono::choose z ) const

- > std::chrono::sys_time < std::common_type_t <Duration, std::chrono::seconds >> ;
(2) (since C++20)

Converts the local_time tp in this time zone to the corresponding sys_time.

1) Throws an exception if the conversion is ambiguous or if tp represents a nonexistent time.
2) Resolves ambiguity according to the value of z:
  • If z == std:: chrono :: choose :: earliest , returns the earlier sys_time
  • If z == std:: chrono :: choose :: latest , returns the later sys_time
If tp represents a nonexistent time between two UTC time_points, those two time_points will be the same, and that time_point

Return value

The UTC equivalent of tp according to the rules of this time zone.

Exceptions

Notes

The precision of the result is at least std::chrono::seconds, and will be finer if the argument has finer precision.

Ambiguous and nonexistent local times can occur as a result of time zone transitions (such as daylight saving time). For example, "2016-03-13 02:30:00" does not exist in the "America/New_York" time zone, while "2016-11-06 01:30:00" in that time zone can correspond to two UTC time points: 2016 - 11 - 06 05 : 30 : 00 and 2016 - 11 - 06 06 : 30 : 00

Example