std::chrono...ote_version,(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

ok so this page is about std::chrono::get_tzdb_list, std::chrono::get_tzdb, and std::chrono::remote_version β€” bestie, these are your time zone database access girlies ✨ (yes, cppreference threw reload_tzdb in the synopsis too, we'll get to her πŸ’…)

oh and for the record, this is a page from the C++ Standard Libary manual (that's their spelling, not mine, love them tho 🫢).


🌸 Synopsis 🌸

std::chrono::tzdb_list& get_tzdb_list(); (1) (since C++20)
const std::chrono::tzdb& get_tzdb();     (2) (since C++20)
std::string remote_version();            (3) (since C++20)
const std::chrono::tzdb& reload_tzdb();  (4) (since C++20)

These functions literally give you access to the program-wide time zone database. main character energy, no cap πŸ‘‘

  1. Returns a reference to the global std::chrono::tzdb_list singleton. If this is the first access to the database, it initializes the database. After the initialization, the database will hold a single initialized std::chrono::tzdb object. This function is thread-safe: concurrent calls to this function from multiple threads do not introduce a data race. slay 🧚
  2. Returns a reference to the first std::chrono::tzdb object held by the tzdb_list singleton. It's equivalent to std::chrono::get_tzdb_list().front(). iykyk πŸ’«
  3. Returns a string containing the latest remote database version. iconic.
  4. If remote_version() != get_tzdb().version, it pushes a new tzdb object representing the remote database to the front of the tzdb_list singleton referenced by get_tzdb_list(). Otherwise there are no effects β€” literally nothing happens, we love a low-effort queen πŸ™ˆ No references, pointers or iterators are invalidated. Calling this function concurrently with get_tzdb_list().front() or get_tzdb_list().erase_after() does not introduce a data race. 🩷

😭 Exceptions 😭

  1. std::runtime_error if for any reason a reference to a tzdb_list containing one or more valid tzdb cannot be returned. like... if it can't even, it throws. periodt πŸ’€

πŸŽ€ Return value πŸŽ€

  1. A reference to the global std::chrono::tzdb_list singleton.
  2. std::chrono::get_tzdb_list().front().
  3. A string containing the latest remote database version.
  4. std::chrono::get_tzdb_list().front() (after any update made by this function).

ok bestie real talk: item (1) is the only one with a documented exception, and (4) is the only one that can quietly change the database under you β€” but it still promises not to invalidate references, pointers or iterators, and it plays nice (no data race) with get_tzdb_list().front() and get_tzdb_list().erase_after(). that's the whole tea πŸ“

and that's the page!! mwah πŸ’‹ this sweet little writeup is straight from http://cppreference.com, dated 2024.06.10 β€” go give them a follow and hydrate, ily, bye πŸ’œπŸŒˆβ­

πŸ“¦ where this page comes from