29 Time library [time]

29.11 Time zones [time.zone]

29.11.1 In general [time.zone.general]

[time.zone] describes an interface for accessing the IANA Time Zone Database[bib] that interoperates with sys_time and local_time.
This interface provides time zone support to both the civil calendar types ([time.cal]) and to user-defined calendars.

29.11.2 Time zone database [time.zone.db]

29.11.2.1 Class tzdb [time.zone.db.tzdb]

namespace std::chrono { struct tzdb { string version; vector<time_zone> zones; vector<time_zone_link> links; vector<leap_second> leap_seconds; const time_zone* locate_zone(string_view tz_name) const; const time_zone* current_zone() const; }; }
Each vector in a tzdb object is sorted to enable fast lookup.
const time_zone* locate_zone(string_view tz_name) const;
Returns:
  • If zones contains an element tz for which tz.name() == tz_name, a pointer to tz;
  • otherwise, if links contains an element tz_l for which tz_l.name() == tz_name, then a pointer to the element tz of zones for which tz.name() == tz_l.target().
[Note 1: 
A time_zone_link specifies an alternative name for a time_zone.
β€” end note]
Throws: If a const time_zone* cannot be found as described in the Returns: element, throws a runtime_error.
[Note 2: 
On non-exceptional return, the return value is always a pointer to a valid time_zone.
β€” end note]
const time_zone* current_zone() const;
Returns: A pointer to the time zone which the computer has set as its local time zone.

29.11.2.2 Class tzdb_list [time.zone.db.list]

namespace std::chrono { class tzdb_list { public: tzdb_list(const tzdb_list&) = delete; tzdb_list& operator=(const tzdb_list&) = delete; // unspecified additional constructors class const_iterator; const tzdb& front() const noexcept; const_iterator erase_after(const_iterator p); const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; }; }
The tzdb_list database is a singleton; the unique object of type tzdb_list can be accessed via the get_tzdb_list() function.
[Note 1: 
This access is only needed for those applications that need to have long uptimes and have a need to update the time zone database while running.
Other applications can implicitly access the front() of this list via the read-only namespace scope functions get_tzdb(), locate_zone(), and current_zone().
β€” end note]
The tzdb_list object contains a list of tzdb objects.
tzdb_list​::​const_iterator is a constant iterator which meets the Cpp17ForwardIterator requirements and has a value type of tzdb.
const tzdb& front() const noexcept;
Synchronization: This operation is thread-safe with respect to reload_tzdb().
[Note 2: 
reload_tzdb() pushes a new tzdb onto the front of this container.
β€” end note]
Returns: A reference to the first tzdb in the container.
const_iterator erase_after(const_iterator p);
Preconditions: The iterator following p is dereferenceable.
Effects: Erases the tzdb referred to by the iterator following p.
Postconditions: No pointers, references, or iterators are invalidated except those referring to the erased tzdb.
[Note 3: 
It is not possible to erase the tzdb referred to by begin().
β€” end note]
Returns: An iterator pointing to the element following the one that was erased, or end() if no such element exists.
Throws: Nothing.
const_iterator begin() const noexcept;
Returns: An iterator referring to the first tzdb in the container.
const_iterator end() const noexcept;
Returns: An iterator referring to the position one past the last tzdb in the container.
const_iterator cbegin() const noexcept;
Returns: begin().
const_iterator cend() const noexcept;
Returns: end().

29.11.2.3 Time zone database access [time.zone.db.access]

tzdb_list& get_tzdb_list();
Effects: If this is the first access to the time zone database, initializes the database.
If this call initializes the database, the resulting database will be a tzdb_list holding a single initialized tzdb.
Synchronization: It is safe to call this function from multiple threads at one time.
Returns: A reference to the database.
Throws: runtime_error if for any reason a reference cannot be returned to a valid tzdb_list containing one or more valid tzdbs.
const tzdb& get_tzdb();
Returns: get_tzdb_list().front().
const time_zone* locate_zone(string_view tz_name);
Returns: get_tzdb().locate_zone(tz_name).
[Note 1: 
The time zone database will be initialized if this is the first reference to the database.
β€” end note]
const time_zone* current_zone();
Returns: get_tzdb().current_zone().

29.11.2.4 Remote time zone database support [time.zone.db.remote]

The local time zone database is that supplied by the implementation when the program first accesses the database, for example via current_zone().
While the program is running, the implementation may choose to update the time zone database.
This update shall not impact the program in any way unless the program calls the functions in this subclause.
This potentially updated time zone database is referred to as the remote time zone database.
const tzdb& reload_tzdb();
Effects: This function first checks the version of the remote time zone database.
If the versions of the local and remote databases are the same, there are no effects.
Otherwise the remote database is pushed to the front of the tzdb_list accessed by get_tzdb_list().
Synchronization: This function is thread-safe with respect to get_tzdb_list().front() and get_tzdb_list().erase_after().
Postconditions: No pointers, references, or iterators are invalidated.
Returns: get_tzdb_list().front().
Throws: runtime_error if for any reason a reference cannot be returned to a valid tzdb.
string remote_version();
Returns: The latest remote database version.
[Note 1: 
This can be compared with get_tzdb().version to discover if the local and remote databases are equivalent.
β€” end note]

29.11.3 Exception classes [time.zone.exception]

29.11.3.1 Class nonexistent_local_time [time.zone.exception.nonexist]

namespace std::chrono { class nonexistent_local_time : public runtime_error { public: template<class Duration> nonexistent_local_time(const local_time<Duration>& tp, const local_info& i); }; }
nonexistent_local_time is thrown when an attempt is made to convert a non-existent local_time to a sys_time without specifying choose​::​earliest or choose​::​latest.
template<class Duration> nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
Preconditions: i.result == local_info​::​nonexistent is true.
Effects: Initializes the base class with a sequence of char equivalent to that produced by os.str() initialized as shown below: ostringstream os; os << tp << " is in a gap between\n" << local_seconds{i.first.end.time_since_epoch()} + i.first.offset << ' ' << i.first.abbrev << " and\n" << local_seconds{i.second.begin.time_since_epoch()} + i.second.offset << ' ' << i.second.abbrev << " which are both equivalent to\n" << i.first.end << " UTC";
[Example 1: #include <chrono> #include <iostream> int main() { using namespace std::chrono; try { auto zt = zoned_time{"America/New_York", local_days{Sunday[2]/March/2016} + 2h + 30min}; } catch (const nonexistent_local_time& e) { std::cout << e.what() << '\n'; } }
Produces the output:
2016-03-13 02:30:00 is in a gap between
2016-03-13 02:00:00 EST and
2016-03-13 03:00:00 EDT which are both equivalent to
2016-03-13 07:00:00 UTC
β€” end example]

29.11.3.2 Class ambiguous_local_time [time.zone.exception.ambig]

namespace std::chrono { class ambiguous_local_time : public runtime_error { public: template<class Duration> ambiguous_local_time(const local_time<Duration>& tp, const local_info& i); }; }
ambiguous_local_time is thrown when an attempt is made to convert an ambiguous local_time to a sys_time without specifying choose​::​earliest or choose​::​latest.
template<class Duration> ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
Preconditions: i.result == local_info​::​ambiguous is true.
Effects: Initializes the base class with a sequence of char equivalent to that produced by os.str() initialized as shown below: ostringstream os; os << tp << " is ambiguous. It could be\n" << tp << ' ' << i.first.abbrev << " == " << tp - i.first.offset << " UTC or\n" << tp << ' ' << i.second.abbrev << " == " << tp - i.second.offset << " UTC";
[Example 1: #include <chrono> #include <iostream> int main() { using namespace std::chrono; try { auto zt = zoned_time{"America/New_York", local_days{Sunday[1]/November/2016} + 1h + 30min}; } catch (const ambiguous_local_time& e) { std::cout << e.what() << '\n'; } }
Produces the output:
2016-11-06 01:30:00 is ambiguous.  It could be
2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or
2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC
β€” end example]

29.11.4 Information classes [time.zone.info]

29.11.4.1 Class sys_info [time.zone.info.sys]

namespace std::chrono { struct sys_info { sys_seconds begin; sys_seconds end; seconds offset; minutes save; string abbrev; }; }
A sys_info object can be obtained from the combination of a time_zone and either a sys_time or local_time.
It can also be obtained from a zoned_time, which is effectively a pair of a time_zone and sys_time.
[Note 1: 
This type provides a low-level interface to time zone information.
Typical conversions from sys_time to local_time will use this class implicitly, not explicitly.
β€” end note]
The begin and end data members indicate that, for the associated time_zone and time_point, the offset and abbrev are in effect in the range [begin, end).
This information can be used to efficiently iterate the transitions of a time_zone.
The offset data member indicates the UTC offset in effect for the associated time_zone and time_point.
The relationship between local_time and sys_time is: offset = local_time - sys_time
The save data member is extra information not normally needed for conversion between local_time and sys_time.
If save != 0min, this sys_info is said to be on β€œdaylight saving” time, and offset - save suggests what offset this time_zone might use if it were off daylight saving time.
However, this information should not be taken as authoritative.
The only sure way to get such information is to query the time_zone with a time_point that returns a sys_info where save == 0min.
There is no guarantee what time_point might return such a sys_info except that it is guaranteed not to be in the range [begin, end) (if save != 0min for this sys_info).
The abbrev data member indicates the current abbreviation used for the associated time_zone and time_point.
Abbreviations are not unique among the time_zones, and so one cannot reliably map abbreviations back to a time_zone and UTC offset.
template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const sys_info& r);
Effects: Streams out the sys_info object r in an unspecified format.
Returns: os.

29.11.4.2 Class local_info [time.zone.info.local]

namespace std::chrono { struct local_info { static constexpr int unique = 0; static constexpr int nonexistent = 1; static constexpr int ambiguous = 2; int result; sys_info first; sys_info second; }; }
[Note 1: 
This type provides a low-level interface to time zone information.
Typical conversions from local_time to sys_time will use this class implicitly, not explicitly.
β€” end note]
Describes the result of converting a local_time to a sys_time as follows:
  • When a local_time to sys_time conversion is unique, result == unique, first will be filled out with the correct sys_info, and second will be zero-initialized.
  • If the conversion stems from a nonexistent local_time then result == nonexistent, first will be filled out with the sys_info that ends just prior to the local_time, and second will be filled out with the sys_info that begins just after the local_time.
  • If the conversion stems from an ambiguous local_time, then result == ambiguous, first will be filled out with the sys_info that ends just after the local_time, and second will be filled out with the sys_info that starts just before the local_time.
template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const local_info& r);
Effects: Streams out the local_info object r in an unspecified format.
Returns: os.

29.11.5 Class time_zone [time.zone.timezone]

29.11.5.1 Overview [time.zone.overview]

namespace std::chrono { class time_zone { public: time_zone(time_zone&&) = default; time_zone& operator=(time_zone&&) = default; // unspecified additional constructors string_view name() const noexcept; template<class Duration> sys_info get_info(const sys_time<Duration>& st) const; template<class Duration> local_info get_info(const local_time<Duration>& tp) const; template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp) const; template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp, choose z) const; template<class Duration> local_time<common_type_t<Duration, seconds>> to_local(const sys_time<Duration>& tp) const; }; }
A time_zone represents all time zone transitions for a specific geographic area.
time_zone construction is unspecified, and performed as part of database initialization.
[Note 1: 
const time_zone objects can be accessed via functions such as locate_zone.
β€” end note]

29.11.5.2 Member functions [time.zone.members]

string_view name() const noexcept;
Returns: The name of the time_zone.
[Example 1: 
"America/New_York".
β€” end example]
template<class Duration> sys_info get_info(const sys_time<Duration>& st) const;
Returns: A sys_info i for which st is in the range [i.begin, i.end).
template<class Duration> local_info get_info(const local_time<Duration>& tp) const;
Returns: A local_info for tp.
template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp) const;
Returns: A sys_time that is at least as fine as seconds, and will be finer if the argument tp has finer precision.
This sys_time is the UTC equivalent of tp according to the rules of this time_zone.
Throws: If the conversion from tp to a sys_time is ambiguous, throws ambiguous_local_time.
If the tp represents a non-existent time between two UTC time_points, throws nonexistent_local_time.
template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp, choose z) const;
Returns: A sys_time that is at least as fine as seconds, and will be finer if the argument tp has finer precision.
This sys_time is the UTC equivalent of tp according to the rules of this time_zone.
If the conversion from tp to a sys_time is ambiguous, returns the earlier sys_time if z == choose​::​earliest, and returns the later sys_time if z == choose​::​latest.
If the tp represents a non-existent time between two UTC time_points, then the two UTC time_points will be the same, and that UTC time_point will be returned.
template<class Duration> local_time<common_type_t<Duration, seconds>> to_local(const sys_time<Duration>& tp) const;
Returns: The local_time associated with tp and this time_zone.

29.11.5.3 Non-member functions [time.zone.nonmembers]

bool operator==(const time_zone& x, const time_zone& y) noexcept;
Returns: x.name() == y.name().
strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept;
Returns: x.name() <=> y.name().

29.11.6 Class template zoned_traits [time.zone.zonedtraits]

namespace std::chrono { template<class T> struct zoned_traits {}; }
zoned_traits provides a means for customizing the behavior of zoned_time<Duration, TimeZonePtr> for the zoned_time default constructor, and constructors taking string_view.
A specialization for const time_zone* is provided by the implementation: namespace std::chrono { template<> struct zoned_traits<const time_zone*> { static const time_zone* default_zone(); static const time_zone* locate_zone(string_view name); }; }
static const time_zone* default_zone();
Returns: std​::​chrono​::​locate_zone("UTC").
static const time_zone* locate_zone(string_view name);
Returns: std​::​chrono​::​locate_zone(name).

29.11.7 Class template zoned_time [time.zone.zonedtime]

29.11.7.1 Overview [time.zone.zonedtime.overview]

namespace std::chrono { template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time { public: using duration = common_type_t<Duration, seconds>; private: TimeZonePtr zone_; // exposition only sys_time<duration> tp_; // exposition only using traits = zoned_traits<TimeZonePtr>; // exposition only public: zoned_time(); zoned_time(const zoned_time&) = default; zoned_time& operator=(const zoned_time&) = default; zoned_time(const sys_time<Duration>& st); explicit zoned_time(TimeZonePtr z); explicit zoned_time(string_view name); template<class Duration2> zoned_time(const zoned_time<Duration2, TimeZonePtr>& y); zoned_time(TimeZonePtr z, const sys_time<Duration>& st); zoned_time(string_view name, const sys_time<Duration>& st); zoned_time(TimeZonePtr z, const local_time<Duration>& tp); zoned_time(string_view name, const local_time<Duration>& tp); zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c); zoned_time(string_view name, const local_time<Duration>& tp, choose c); template<class Duration2, class TimeZonePtr2> zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y); template<class Duration2, class TimeZonePtr2> zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y, choose); template<class Duration2, class TimeZonePtr2> zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y); template<class Duration2, class TimeZonePtr2> zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y, choose c); zoned_time& operator=(const sys_time<Duration>& st); zoned_time& operator=(const local_time<Duration>& lt); operator sys_time<duration>() const; explicit operator local_time<duration>() const; TimeZonePtr get_time_zone() const; local_time<duration> get_local_time() const; sys_time<duration> get_sys_time() const; sys_info get_info() const; }; zoned_time() -> zoned_time<seconds>; template<class Duration> zoned_time(sys_time<Duration>) -> zoned_time<common_type_t<Duration, seconds>>; template<class TimeZonePtrOrName> using time-zone-representation = // exposition only conditional_t<is_convertible_v<TimeZonePtrOrName, string_view>, const time_zone*, remove_cvref_t<TimeZonePtrOrName>>; template<class TimeZonePtrOrName> zoned_time(TimeZonePtrOrName&&) -> zoned_time<seconds, time-zone-representation<TimeZonePtrOrName>>; template<class TimeZonePtrOrName, class Duration> zoned_time(TimeZonePtrOrName&&, sys_time<Duration>) -> zoned_time<common_type_t<Duration, seconds>, time-zone-representation<TimeZonePtrOrName>>; template<class TimeZonePtrOrName, class Duration> zoned_time(TimeZonePtrOrName&&, local_time<Duration>, choose = choose::earliest) -> zoned_time<common_type_t<Duration, seconds>, time-zone-representation<TimeZonePtrOrName>>; template<class Duration, class TimeZonePtrOrName, class TimeZonePtr2> zoned_time(TimeZonePtrOrName&&, zoned_time<Duration, TimeZonePtr2>, choose = choose::earliest) -> zoned_time<common_type_t<Duration, seconds>, time-zone-representation<TimeZonePtrOrName>>; }
zoned_time represents a logical pairing of a time_zone and a time_point with precision Duration.
zoned_time<Duration> maintains the invariant that it always refers to a valid time zone and represents a point in time that exists and is not ambiguous in that time zone.
If Duration is not a specialization of chrono​::​duration, the program is ill-formed.
Every constructor of zoned_time that accepts a string_view as its first parameter does not participate in class template argument deduction ([over.match.class.deduct]).

29.11.7.2 Constructors [time.zone.zonedtime.ctor]

zoned_time();
Constraints: traits​::​default_zone() is a well-formed expression.
Effects: Initializes zone_ with traits​::​default_zone() and default constructs tp_.
zoned_time(const sys_time<Duration>& st);
Constraints: traits​::​default_zone() is a well-formed expression.
Effects: Initializes zone_ with traits​::​default_zone() and tp_ with st.
explicit zoned_time(TimeZonePtr z);
Preconditions: z refers to a time zone.
Effects: Initializes zone_ with std​::​move(z) and default constructs tp_.
explicit zoned_time(string_view name);
Constraints: traits​::​locate_zone(string_view{}) is a well-formed expression and zoned_time is constructible from the return type of traits​::​locate_zone(string_view{}).
Effects: Initializes zone_ with traits​::​locate_zone(name) and default constructs tp_.
template<class Duration2> zoned_time(const zoned_time<Duration2, TimeZonePtr>& y);
Constraints: is_convertible_v<sys_time<Duration2>, sys_time<Duration>> is true.
Effects: Initializes zone_ with y.zone_ and tp_ with y.tp_.
zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
Preconditions: z refers to a time zone.
Effects: Initializes zone_ with std​::​move(z) and tp_ with st.
zoned_time(string_view name, const sys_time<Duration>& st);
Constraints: zoned_time is constructible from the return type of traits​::​locate_zone(name) and st.
Effects: Equivalent to construction with {traits​::​locate_zone(name), st}.
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
Constraints: is_convertible_v< decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{})), sys_time<duration>> is true.
Preconditions: z refers to a time zone.
Effects: Initializes zone_ with std​::​move(z) and tp_ with zone_->to_sys(tp).
zoned_time(string_view name, const local_time<Duration>& tp);
Constraints: zoned_time is constructible from the return type of traits​::​locate_zone(name) and tp.
Effects: Equivalent to construction with {traits​::​locate_zone(name), tp}.
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
Constraints: is_convertible_v< decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{}, choose::earliest)), sys_time<duration>> is true.
Preconditions: z refers to a time zone.
Effects: Initializes zone_ with std​::​move(z) and tp_ with zone_->to_sys(tp, c).
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
Constraints: zoned_time is constructible from the return type of traits​::​locate_zone(name), local_time<Duration>, and choose.
Effects: Equivalent to construction with {traits​::​locate_zone(name), tp, c}.
template<class Duration2, class TimeZonePtr2> zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y);
Constraints: is_convertible_v<sys_time<Duration2>, sys_time<Duration>> is true.
Preconditions: z refers to a valid time zone.
Effects: Initializes zone_ with std​::​move(z) and tp_ with y.tp_.
template<class Duration2, class TimeZonePtr2> zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y, choose);
Constraints: is_convertible_v<sys_time<Duration2>, sys_time<Duration>> is true.
Preconditions: z refers to a valid time zone.
Effects: Equivalent to construction with {z, y}.
[Note 1: 
The choose parameter has no effect.
β€” end note]
template<class Duration2, class TimeZonePtr2> zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y);
Constraints: zoned_time is constructible from the return type of traits​::​locate_zone(name) and the type zoned_time<Duration2, TimeZonePtr2>.
Effects: Equivalent to construction with {traits​::​locate_zone(name), y}.
template<class Duration2, class TimeZonePtr2> zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y, choose c);
Constraints: zoned_time is constructible from the return type of traits​::​locate_zone(name), the type zoned_time<Duration2, TimeZonePtr2>, and the type choose.
Effects: Equivalent to construction with {traits​::​locate_zone(name), y, c}.
[Note 2: 
The choose parameter has no effect.
β€” end note]

29.11.7.3 Member functions [time.zone.zonedtime.members]

zoned_time& operator=(const sys_time<Duration>& st);
Effects: After assignment, get_sys_time() == st.
This assignment has no effect on the return value of get_time_zone().
Returns: *this.
zoned_time& operator=(const local_time<Duration>& lt);
Effects: After assignment, get_local_time() == lt.
This assignment has no effect on the return value of get_time_zone().
Returns: *this.
operator sys_time<duration>() const;
Returns: get_sys_time().
explicit operator local_time<duration>() const;
Returns: get_local_time().
TimeZonePtr get_time_zone() const;
Returns: zone_.
local_time<duration> get_local_time() const;
Returns: zone_->to_local(tp_).
sys_time<duration> get_sys_time() const;
Returns: tp_.
sys_info get_info() const;
Returns: zone_->get_info(tp_).

29.11.7.4 Non-member functions [time.zone.zonedtime.nonmembers]

template<class Duration1, class Duration2, class TimeZonePtr> bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, const zoned_time<Duration2, TimeZonePtr>& y);
Returns: x.zone_ == y.zone_ && x.tp_ == y.tp_.
template<class charT, class traits, class Duration, class TimeZonePtr> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const zoned_time<Duration, TimeZonePtr>& t);
Effects: Equivalent to: return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%F %T %Z}"), t);

29.11.8 Class leap_second [time.zone.leap]

29.11.8.1 Overview [time.zone.leap.overview]

namespace std::chrono { class leap_second { public: leap_second(const leap_second&) = default; leap_second& operator=(const leap_second&) = default; // unspecified additional constructors constexpr sys_seconds date() const noexcept; constexpr seconds value() const noexcept; }; }
Objects of type leap_second representing the date and value of the leap second insertions are constructed and stored in the time zone database when initialized.
[Example 1: for (auto& l : get_tzdb().leap_seconds) if (l <= sys_days{2018y/March/17d}) cout << l.date() << ": " << l.value() << '\n';
Produces the output:
1972-07-01 00:00:00: 1s
1973-01-01 00:00:00: 1s
1974-01-01 00:00:00: 1s
1975-01-01 00:00:00: 1s
1976-01-01 00:00:00: 1s
1977-01-01 00:00:00: 1s
1978-01-01 00:00:00: 1s
1979-01-01 00:00:00: 1s
1980-01-01 00:00:00: 1s
1981-07-01 00:00:00: 1s
1982-07-01 00:00:00: 1s
1983-07-01 00:00:00: 1s
1985-07-01 00:00:00: 1s
1988-01-01 00:00:00: 1s
1990-01-01 00:00:00: 1s
1991-01-01 00:00:00: 1s
1992-07-01 00:00:00: 1s
1993-07-01 00:00:00: 1s
1994-07-01 00:00:00: 1s
1996-01-01 00:00:00: 1s
1997-07-01 00:00:00: 1s
1999-01-01 00:00:00: 1s
2006-01-01 00:00:00: 1s
2009-01-01 00:00:00: 1s
2012-07-01 00:00:00: 1s
2015-07-01 00:00:00: 1s
2017-01-01 00:00:00: 1s
β€” end example]

29.11.8.2 Member functions [time.zone.leap.members]

constexpr sys_seconds date() const noexcept;
Returns: The date and time at which the leap second was inserted.
constexpr seconds value() const noexcept;
Returns: +1s to indicate a positive leap second or -1s to indicate a negative leap second.
[Note 1: 
All leap seconds inserted up through 2022 were positive leap seconds.
β€” end note]

29.11.8.3 Non-member functions [time.zone.leap.nonmembers]

constexpr bool operator==(const leap_second& x, const leap_second& y) noexcept;
Returns: x.date() == y.date().
constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y) noexcept;
Returns: x.date() <=> y.date().
template<class Duration> constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y) noexcept;
Returns: x.date() == y.
template<class Duration> constexpr bool operator<(const leap_second& x, const sys_time<Duration>& y) noexcept;
Returns: x.date() < y.
template<class Duration> constexpr bool operator<(const sys_time<Duration>& x, const leap_second& y) noexcept;
Returns: x < y.date().
template<class Duration> constexpr bool operator>(const leap_second& x, const sys_time<Duration>& y) noexcept;
Returns: y < x.
template<class Duration> constexpr bool operator>(const sys_time<Duration>& x, const leap_second& y) noexcept;
Returns: y < x.
template<class Duration> constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y) noexcept;
Returns: !(y < x).
template<class Duration> constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y) noexcept;
Returns: !(y < x).
template<class Duration> constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y) noexcept;
Returns: !(x < y).
template<class Duration> constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y) noexcept;
Returns: !(x < y).
template<class Duration> requires three_way_comparable_with<sys_seconds, sys_time<Duration>> constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;
Returns: x.date() <=> y.