std::chrono::locate_zone - cppreference.com (original) (raw)
Convenience function for locating a time zone in the time zone database. Equivalent to std::chrono::get_tzdb().locate_zone(tz_name).
[edit] Parameters
tz_name | - | a time zone name to locate |
---|
[edit] Exceptions
std::runtime_error if the specified time zone cannot be found, or if this is the first reference to the time zone database and the time zone database cannot be initialized.
[edit] Notes
A call to this function that is the first reference to the time zone database will cause it to be initialized.
[edit] Example
#include #include int main() { try { for (const auto zone : {"Atlantic/Bermuda", "Alcatraz"}) std::cout << std::chrono::locate_zone(zone)->name() << '\n'; } catch(const std::runtime_error& ex) { std::cout << ex.what() << '\n'; } }
Possible output:
Atlantic/Bermuda std::chrono::tzdb: cannot locate zone: Alcatraz