std::chrono::current_zone(3)
β¨ std::chrono::current_zone β¨
okay bestie, this is the std::chrono::current_zone(3) page from the C++ Standard Libary man pages β yes, the header really spells it βLibary,β and weβre preserving the source no cap π. Itβs giving βtiny but mighty C++ time zone moment,β and honestly? iconic π
π NAME π
std::chrono::current_zone β literally std::chrono::current_zone, bestie. Thatβs the whole name. Short, sweet, no notes β¨
πΈ Synopsis πΈ
Defined in header <chrono> β yes, the chrono girlies know π°οΈ
const std::chrono::time_zone* current_zone(); (since C++20)
Itβs the convenience function for obtaining your local time zone from the time zone database. Equivalent to std::chrono::get_tzdb().current_zone(). Lowkey a shortcut, highkey useful π
π«Ά Exceptions π«Ά
bestie, listen: std::runtime_error if this is the first reference to the time zone database and the time zone database cannot be initialized. Thatβs the βthe vibe check failedβ case π
π§ Notes π§
A call to this function that is the first reference to the time zone database will cause it to be initialized. So yeah, first touch = init time. Not me accidentally waking up the whole database on the first call πβ¨
π Example π
// Run this code
#include <chrono>
#include <iostream>
int main() {
const std::chrono::zoned_time cur_time{
std::chrono::current_zone(),
std::chrono::system_clock::now()
};
std::cout << cur_time << '\n';
}
Possible output:
2021-09-13 19:46:42.249182012 MAGT
π See also π
current_zoneβ return the local time zone (public member function ofstd::chrono::tzdb)get_tzdbget_tzdb_listβ accesses and controls the global time zone database informationreload_tzdbβ (function)remote_versionβ (C++20)
mwah π this page was served from http://cppreference.com, version/date 2024.06.10, and its title is std::chrono::current_zone(3). Now go forth and get your local time zone, bestie β periodt ππ¦β¨
π¦ 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