Daily bit(e) of C++ | std::chrono - time zones
Daily bit(e) of C++ ♻️76, Handling time zones and zoned times using C++20 std::chrono.
Time zones are a particularly annoying problem when dealing with time. The C++20 extension to std::chrono also introduced support for time zones.
The list of supported time zones can be queried through the time zone database. Alternatively, a time zone can be located directly using its name.
While std::chrono::sys_time is always UTC, the library now also supports unzoned time in the form of std::chrono::local_time. Unzoned time can be combined with a specific time zone to produce a std::chrono::zoned_time, which can then be converted to other time zones.