std::chrono::zoned_traits(3)

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

🌸 NAME 🌸

std::chrono::zoned_traits β€” std::chrono::zoned_traits

okay so bestie, this is the std::chrono::zoned_traits(3) page from the C++ Standard Library manual, and it’s lowkey iconic if you’re messing with custom time zone pointer types. πŸ’…


✨ Synopsis ✨

Defined in header <chrono>
template < class TimeZonePtr >                      (1) (since C++20)
struct zoned_traits { };
template <>                                         (2) (since C++20)
struct zoned_traits<const std::chrono::time_zone*>;

So zoned_traits is literally the customization hook for the behavior of the constructors of std::chrono::zoned_time when you roll with custom time zone pointer types. In particular, it allows such types to specify the default time zone to use and the mapping of a time zone’s name to the corresponding time zone pointer. πŸ¦‹

No cap, it’s totally acceptable for custom time zone pointer types to not support either operation β€” and when that happens, the corresponding constructors of zoned_time will not participate in overload resolution. That’s the vibe check, iykyk. 🫢

The primary template is empty. There’s a specialization provided for const std::chrono::time_zone*, which is the default time zone pointer type. 🌈


πŸŽ€ Member functions πŸŽ€

πŸ’– std::chrono::zoned_traits<const std::chrono::time_zone*>::default_zone πŸ’–

static const std::chrono::time_zone* default_zone();

This one returns a time zone pointer for the default time zone (UTC). ⭐

πŸ’– Return value πŸ’–

It’s std::chrono::locate_zone("UTC") β€” periodt. ✨


πŸ¦‹ std::chrono::zoned_traits<const std::chrono::time_zone*>::locate_zone πŸ¦‹

static const std::chrono::time_zone* locate_zone(std::string_view name);

This one returns the time zone pointer for the time zone designated by name. πŸ‘‘

πŸ’– Return value πŸ’–

It’s std::chrono::locate_zone(name). Slay. πŸ’…


ok bye bestie 🫢 this came from http://cppreference.com, with the footer date 2024.06.10, and it’s the std::chrono::zoned_traits(3) manual page. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from