std::chrono...one::to_sys(3)
π NAME π
okay so this is std::chrono...one::to_sys(3), straight out of the C++ Standard Libary manual (yes, that spelling is literally in the header, iykyk π
). The name is std::chrono::time_zone::to_sys β std::chrono::time_zone::to_sys. Iconic. Periodt.
π Synopsis π
bestie, here's the signature situation. Both overloads are since C++20, and they convert the local_time tp in this time zone to the corresponding sys_time. It's giving timezone glow-up for your timestamp β¨.
Overload (1) β since C++20:
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>>;
Overload (2) β 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>>;
So like, to_sys converts the local_time tp in this time zone to the corresponding sys_time.
- Overload (1) throws an exception if the conversion is ambiguous or if
tprepresents a nonexistent time. No cap, it will absolutely throw. - Overload (2) resolves ambiguity according to the value of
z:- If
z == std::chrono::choose::earliest, returns the earliersys_time. - If
z == std::chrono::choose::latest, returns the latersys_time.
- If
If tp represents a nonexistent time between two UTC time_points, those two time_points will be the same, and that time_point will be returned. That's the rule, bestie.
π Return value π
The UTC equivalent of tp according to the rules of this time zone. That's the whole vibe. π
π Exceptions π
- Overload (1) throws:
std::chrono::ambiguous_local_timeif the conversion is ambiguous,std::chrono::nonexistent_local_timeiftprepresents a nonexistent time.
π§ Notes π§
The precision of the result is at least std::chrono::seconds, and will be finer if the argument has finer precision. So seconds is the floor, not the ceiling, bestie β¨.
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 UTC and 2016-11-06 06:30:00 UTC. That is not a glitch, it is DST being DST π.
π Example π
This section is incomplete.
Reason: no example.
Literally it says that, I'm not hiding anything π.
ποΈ Category ποΈ
- Todo no example
okay bestie, that's the page. source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::chrono...one::to_sys(3) β go forth and convert those local times, but watch out for DST chaos πΈπ
.
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms