Files
2025-10-25 03:02:53 +03:00

6.8 KiB
Raw Permalink Blame History

[time.zone.leap]

30 Time library [time]

30.11 Time zones [time.zone]

30.11.8 Class leap_second [time.zone.leap]

30.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 constructorsconstexpr sys_seconds date() const noexcept; constexpr seconds value() const noexcept; };}

1

#

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.

2

#

[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]

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

🔗

constexpr sys_seconds date() const noexcept;

1

#

Returns: The date and time at which the leap second was inserted.

🔗

constexpr seconds value() const noexcept;

2

#

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]

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

🔗

constexpr bool operator==(const leap_second& x, const leap_second& y) noexcept;

1

#

Returns: x.date() == y.date().

🔗

constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y) noexcept;

2

#

Returns: x.date() <=> y.date().

🔗

template<class Duration> constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y) noexcept;

3

#

Returns: x.date() == y.

🔗

template<class Duration> constexpr bool operator<(const leap_second& x, const sys_time<Duration>& y) noexcept;

4

#

Returns: x.date() < y.

🔗

template<class Duration> constexpr bool operator<(const sys_time<Duration>& x, const leap_second& y) noexcept;

5

#

Returns: x < y.date().

🔗

template<class Duration> constexpr bool operator>(const leap_second& x, const sys_time<Duration>& y) noexcept;

6

#

Returns: y < x.

🔗

template<class Duration> constexpr bool operator>(const sys_time<Duration>& x, const leap_second& y) noexcept;

7

#

Returns: y < x.

🔗

template<class Duration> constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y) noexcept;

8

#

Returns: !(y < x).

🔗

template<class Duration> constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y) noexcept;

9

#

Returns: !(y < x).

🔗

template<class Duration> constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y) noexcept;

10

#

Returns: !(x < y).

🔗

template<class Duration> constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y) noexcept;

11

#

Returns: !(x < y).

🔗

template<class Duration> requires [three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4Concept three_­way_­comparable[cmp.concept]")<sys_seconds, sys_time<Duration>> constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;

12

#

Returns: x.date() <=> y.