1664 lines
58 KiB
Markdown
1664 lines
58 KiB
Markdown
[time.zone]
|
||
|
||
# 30 Time library [[time]](./#time)
|
||
|
||
## 30.11 Time zones [time.zone]
|
||
|
||
### [30.11.1](#general) General [[time.zone.general]](time.zone.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8726)
|
||
|
||
[time.zone] describes an interface for accessing
|
||
the IANA Time Zone Database[[bib]](bibliography#bib:iana-tz "Bibliography") that interoperates with sys_time and local_time[.](#general-1.sentence-1)
|
||
|
||
This interface provides time zone support to
|
||
both the civil calendar types ([[time.cal]](time.cal "30.8 The civil calendar"))
|
||
and to user-defined calendars[.](#general-1.sentence-2)
|
||
|
||
### [30.11.2](#db) Time zone database [[time.zone.db]](time.zone.db)
|
||
|
||
#### [30.11.2.1](#db.tzdb) Class tzdb [[time.zone.db.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; };}
|
||
|
||
[1](#db.tzdb-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8753)
|
||
|
||
Each vector in a tzdb object
|
||
is sorted to enable fast lookup[.](#db.tzdb-1.sentence-1)
|
||
|
||
[ð](#lib:locate_zone,tzdb)
|
||
|
||
`const time_zone* locate_zone(string_view tz_name) const;
|
||
`
|
||
|
||
[2](#db.tzdb-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8763)
|
||
|
||
*Returns*:
|
||
|
||
- [(2.1)](#db.tzdb-2.1)
|
||
|
||
If zones contains an element tz for which tz.name() == tz_name,
|
||
a pointer to tz;
|
||
|
||
- [(2.2)](#db.tzdb-2.2)
|
||
|
||
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()[.](#db.tzdb-2.sentence-1)
|
||
|
||
[*Note [1](#db.tzdb-note-1)*:
|
||
|
||
A time_zone_link specifies an alternative name for a time_zone[.](#db.tzdb-2.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[3](#db.tzdb-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8781)
|
||
|
||
*Throws*: If a const time_zone* cannot be found
|
||
as described in the *Returns*: element,
|
||
throws a runtime_error[.](#db.tzdb-3.sentence-1)
|
||
|
||
[*Note [2](#db.tzdb-note-2)*:
|
||
|
||
On non-exceptional return, the return value is always a pointer to a valid time_zone[.](#db.tzdb-3.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:current_zone,tzdb)
|
||
|
||
`const time_zone* current_zone() const;
|
||
`
|
||
|
||
[4](#db.tzdb-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8797)
|
||
|
||
*Returns*: A pointer to the time zone which the computer has set as its local time zone[.](#db.tzdb-4.sentence-1)
|
||
|
||
#### [30.11.2.2](#db.list) Class tzdb_list [[time.zone.db.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 constructorsclass 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; };}
|
||
|
||
[1](#db.list-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8829)
|
||
|
||
The tzdb_list database is a singleton;
|
||
the unique object of type tzdb_list can be
|
||
accessed via the get_tzdb_list() function[.](#db.list-1.sentence-1)
|
||
|
||
[*Note [1](#db.list-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[.](#db.list-1.sentence-2)
|
||
|
||
Other applications can implicitly access the front() of this list
|
||
via the read-only namespace scope functionsget_tzdb(),locate_zone(), andcurrent_zone()[.](#db.list-1.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
The tzdb_list object contains a list of tzdb objects[.](#db.list-1.sentence-4)
|
||
|
||
[2](#db.list-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8845)
|
||
|
||
tzdb_list::const_iterator is a constant iterator
|
||
which meets the [*Cpp17ForwardIterator*](forward.iterators#:Cpp17ForwardIterator "24.3.5.5 Forward iterators [forward.iterators]") requirements
|
||
and has a value type of tzdb[.](#db.list-2.sentence-1)
|
||
|
||
[ð](#lib:front,tzdb_list)
|
||
|
||
`const tzdb& front() const noexcept;
|
||
`
|
||
|
||
[3](#db.list-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8856)
|
||
|
||
*Synchronization*: This operation is thread-safe with respect to reload_tzdb()[.](#db.list-3.sentence-1)
|
||
|
||
[*Note [2](#db.list-note-2)*:
|
||
|
||
reload_tzdb() pushes a new tzdb onto the front of this container[.](#db.list-3.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[4](#db.list-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8864)
|
||
|
||
*Returns*: A reference to the first tzdb in the container[.](#db.list-4.sentence-1)
|
||
|
||
[ð](#lib:erase_after,tzdb_list)
|
||
|
||
`const_iterator erase_after(const_iterator p);
|
||
`
|
||
|
||
[5](#db.list-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8875)
|
||
|
||
*Preconditions*: The iterator following p is dereferenceable[.](#db.list-5.sentence-1)
|
||
|
||
[6](#db.list-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8879)
|
||
|
||
*Effects*: Erases the tzdb referred to by the iterator following p[.](#db.list-6.sentence-1)
|
||
|
||
[7](#db.list-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8883)
|
||
|
||
*Postconditions*: No pointers, references, or iterators are invalidated
|
||
except those referring to the erased tzdb[.](#db.list-7.sentence-1)
|
||
|
||
[*Note [3](#db.list-note-3)*:
|
||
|
||
It is not possible to erase the tzdb referred to by begin()[.](#db.list-7.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[8](#db.list-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8892)
|
||
|
||
*Returns*: An iterator pointing to the element following the one that was erased,
|
||
or end() if no such element exists[.](#db.list-8.sentence-1)
|
||
|
||
[9](#db.list-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8897)
|
||
|
||
*Throws*: Nothing[.](#db.list-9.sentence-1)
|
||
|
||
[ð](#lib:begin,tzdb_list)
|
||
|
||
`const_iterator begin() const noexcept;
|
||
`
|
||
|
||
[10](#db.list-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8908)
|
||
|
||
*Returns*: An iterator referring to the first tzdb in the container[.](#db.list-10.sentence-1)
|
||
|
||
[ð](#lib:end,tzdb_list)
|
||
|
||
`const_iterator end() const noexcept;
|
||
`
|
||
|
||
[11](#db.list-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8919)
|
||
|
||
*Returns*: An iterator referring to the position one past the last tzdb in the container[.](#db.list-11.sentence-1)
|
||
|
||
[ð](#lib:cbegin,tzdb_list)
|
||
|
||
`const_iterator cbegin() const noexcept;
|
||
`
|
||
|
||
[12](#db.list-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8930)
|
||
|
||
*Returns*: begin()[.](#db.list-12.sentence-1)
|
||
|
||
[ð](#lib:cend,tzdb_list)
|
||
|
||
`const_iterator cend() const noexcept;
|
||
`
|
||
|
||
[13](#db.list-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8941)
|
||
|
||
*Returns*: end()[.](#db.list-13.sentence-1)
|
||
|
||
#### [30.11.2.3](#db.access) Time zone database access [[time.zone.db.access]](time.zone.db.access)
|
||
|
||
[ð](#lib:get_tzdb_list)
|
||
|
||
`tzdb_list& get_tzdb_list();
|
||
`
|
||
|
||
[1](#db.access-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8954)
|
||
|
||
*Effects*: If this is the first access to the time zone database,
|
||
initializes the database[.](#db.access-1.sentence-1)
|
||
|
||
If this call initializes the database,
|
||
the resulting database will be a tzdb_list holding a single initialized tzdb[.](#db.access-1.sentence-2)
|
||
|
||
[2](#db.access-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8962)
|
||
|
||
*Synchronization*: It is safe to call this function from multiple threads at one time[.](#db.access-2.sentence-1)
|
||
|
||
[3](#db.access-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8966)
|
||
|
||
*Returns*: A reference to the database[.](#db.access-3.sentence-1)
|
||
|
||
[4](#db.access-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8970)
|
||
|
||
*Throws*: runtime_error if for any reason
|
||
a reference cannot be returned to a valid tzdb_list containing one or more valid tzdbs[.](#db.access-4.sentence-1)
|
||
|
||
[ð](#lib:get_tzdb)
|
||
|
||
`const tzdb& get_tzdb();
|
||
`
|
||
|
||
[5](#db.access-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8983)
|
||
|
||
*Returns*: get_tzdb_list().front()[.](#db.access-5.sentence-1)
|
||
|
||
[ð](#lib:locate_zone)
|
||
|
||
`const time_zone* locate_zone(string_view tz_name);
|
||
`
|
||
|
||
[6](#db.access-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8994)
|
||
|
||
*Returns*: get_tzdb().locate_zone(tz_name)[.](#db.access-6.sentence-1)
|
||
|
||
[7](#db.access-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L8998)
|
||
|
||
[*Note [1](#db.access-note-1)*:
|
||
|
||
The time zone database will be initialized
|
||
if this is the first reference to the database[.](#db.access-7.sentence-1)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:current_zone)
|
||
|
||
`const time_zone* current_zone();
|
||
`
|
||
|
||
[8](#db.access-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9011)
|
||
|
||
*Returns*: get_tzdb().current_zone()[.](#db.access-8.sentence-1)
|
||
|
||
#### [30.11.2.4](#db.remote) Remote time zone database support [[time.zone.db.remote]](time.zone.db.remote)
|
||
|
||
[1](#db.remote-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9018)
|
||
|
||
The local time zone database
|
||
is that supplied by the implementation
|
||
when the program first accesses the database,
|
||
for example via current_zone()[.](#db.remote-1.sentence-1)
|
||
|
||
While the program is running,
|
||
the implementation may choose to update the time zone database[.](#db.remote-1.sentence-2)
|
||
|
||
This update shall not impact the program in any way
|
||
unless the program calls the functions in this subclause[.](#db.remote-1.sentence-3)
|
||
|
||
This potentially updated time zone database
|
||
is referred to as the [*remote time zone database*](#def:remote_time_zone_database "30.11.2.4 Remote time zone database support [time.zone.db.remote]")[.](#db.remote-1.sentence-4)
|
||
|
||
[ð](#lib:reload_tzdb)
|
||
|
||
`const tzdb& reload_tzdb();
|
||
`
|
||
|
||
[2](#db.remote-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9036)
|
||
|
||
*Effects*: This function first checks
|
||
the version of the remote time zone database[.](#db.remote-2.sentence-1)
|
||
|
||
If the versions of the local and remote databases are the same,
|
||
there are no effects[.](#db.remote-2.sentence-2)
|
||
|
||
Otherwise the remote database is pushed
|
||
to the front of the tzdb_list accessed by get_tzdb_list()[.](#db.remote-2.sentence-3)
|
||
|
||
[3](#db.remote-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9046)
|
||
|
||
*Synchronization*: This function is thread-safe with respect toget_tzdb_list().front() and get_tzdb_list().erase_after()[.](#db.remote-3.sentence-1)
|
||
|
||
[4](#db.remote-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9051)
|
||
|
||
*Postconditions*: No pointers, references, or iterators are invalidated[.](#db.remote-4.sentence-1)
|
||
|
||
[5](#db.remote-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9055)
|
||
|
||
*Returns*: get_tzdb_list().front()[.](#db.remote-5.sentence-1)
|
||
|
||
[6](#db.remote-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9059)
|
||
|
||
*Throws*: runtime_error if for any reason
|
||
a reference cannot be returned to a valid tzdb[.](#db.remote-6.sentence-1)
|
||
|
||
[ð](#lib:remote_version)
|
||
|
||
`string remote_version();
|
||
`
|
||
|
||
[7](#db.remote-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9071)
|
||
|
||
*Returns*: The latest remote database version[.](#db.remote-7.sentence-1)
|
||
|
||
[*Note [1](#db.remote-note-1)*:
|
||
|
||
This can be compared with get_tzdb().version to discover if the local and remote databases are equivalent[.](#db.remote-7.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
### [30.11.3](#exception) Exception classes [[time.zone.exception]](time.zone.exception)
|
||
|
||
#### [30.11.3.1](#exception.nonexist) Class nonexistent_local_time [[time.zone.exception.nonexist]](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); };}
|
||
|
||
[1](#exception.nonexist-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9096)
|
||
|
||
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[.](#exception.nonexist-1.sentence-1)
|
||
|
||
[ð](#lib:nonexistent_local_time,constructor)
|
||
|
||
`template<class Duration>
|
||
nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
|
||
`
|
||
|
||
[2](#exception.nonexist-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9109)
|
||
|
||
*Preconditions*: i.result == local_info::nonexistent is true[.](#exception.nonexist-2.sentence-1)
|
||
|
||
[3](#exception.nonexist-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9113)
|
||
|
||
*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";
|
||
|
||
[4](#exception.nonexist-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9129)
|
||
|
||
[*Example [1](#exception.nonexist-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*]
|
||
|
||
#### [30.11.3.2](#exception.ambig) Class ambiguous_local_time [[time.zone.exception.ambig]](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); };}
|
||
|
||
[1](#exception.ambig-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9169)
|
||
|
||
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[.](#exception.ambig-1.sentence-1)
|
||
|
||
[ð](#lib:ambiguous_local_time,constructor)
|
||
|
||
`template<class Duration>
|
||
ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
|
||
`
|
||
|
||
[2](#exception.ambig-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9182)
|
||
|
||
*Preconditions*: i.result == local_info::ambiguous is true[.](#exception.ambig-2.sentence-1)
|
||
|
||
[3](#exception.ambig-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9186)
|
||
|
||
*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";
|
||
|
||
[4](#exception.ambig-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9200)
|
||
|
||
[*Example [1](#exception.ambig-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*]
|
||
|
||
### [30.11.4](#info) Information classes [[time.zone.info]](time.zone.info)
|
||
|
||
#### [30.11.4.1](#info.sys) Class sys_info [[time.zone.info.sys]](time.zone.info.sys)
|
||
|
||
namespace std::chrono {struct sys_info { sys_seconds begin;
|
||
sys_seconds end;
|
||
seconds offset;
|
||
minutes save;
|
||
string abbrev; };}
|
||
|
||
[1](#info.sys-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9243)
|
||
|
||
A sys_info object can be obtained
|
||
from the combination of a time_zone and
|
||
either a sys_time or local_time[.](#info.sys-1.sentence-1)
|
||
|
||
It can also be obtained from a zoned_time,
|
||
which is effectively a pair of a time_zone and sys_time[.](#info.sys-1.sentence-2)
|
||
|
||
[2](#info.sys-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9250)
|
||
|
||
[*Note [1](#info.sys-note-1)*:
|
||
|
||
This type provides a low-level interface to time zone information[.](#info.sys-2.sentence-1)
|
||
|
||
Typical conversions from sys_time to local_time will use this class implicitly, not explicitly[.](#info.sys-2.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[3](#info.sys-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9257)
|
||
|
||
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)[.](#info.sys-3.sentence-1)
|
||
|
||
This information can be used to efficiently iterate the transitions of a time_zone[.](#info.sys-3.sentence-2)
|
||
|
||
[4](#info.sys-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9265)
|
||
|
||
The offset data member indicates
|
||
the UTC offset in effect
|
||
for the associated time_zone and time_point[.](#info.sys-4.sentence-1)
|
||
|
||
The relationship between local_time and sys_time is:offset = local_time - sys_time
|
||
|
||
[5](#info.sys-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9275)
|
||
|
||
The save data member is extra information not normally needed
|
||
for conversion between local_time and sys_time[.](#info.sys-5.sentence-1)
|
||
|
||
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[.](#info.sys-5.sentence-2)
|
||
|
||
However, this information should not be taken as authoritative[.](#info.sys-5.sentence-3)
|
||
|
||
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[.](#info.sys-5.sentence-4)
|
||
|
||
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)[.](#info.sys-5.sentence-5)
|
||
|
||
[6](#info.sys-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9290)
|
||
|
||
The abbrev data member indicates
|
||
the current abbreviation used for the associated time_zone and time_point[.](#info.sys-6.sentence-1)
|
||
|
||
Abbreviations are not unique among the time_zones,
|
||
and so one cannot reliably map abbreviations back to a time_zone and UTC offset[.](#info.sys-6.sentence-2)
|
||
|
||
[ð](#lib:operator%3c%3c,sys_info)
|
||
|
||
`template<class charT, class traits>
|
||
basic_ostream<charT, traits>&
|
||
operator<<(basic_ostream<charT, traits>& os, const sys_info& r);
|
||
`
|
||
|
||
[7](#info.sys-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9305)
|
||
|
||
*Effects*: Streams out the sys_info object r in an unspecified format[.](#info.sys-7.sentence-1)
|
||
|
||
[8](#info.sys-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9309)
|
||
|
||
*Returns*: os[.](#info.sys-8.sentence-1)
|
||
|
||
#### [30.11.4.2](#info.local) Class local_info [[time.zone.info.local]](time.zone.info.local)
|
||
|
||
[ð](#lib:unique,local_info)
|
||
|
||
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; };}
|
||
|
||
[1](#info.local-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9337)
|
||
|
||
[*Note [1](#info.local-note-1)*:
|
||
|
||
This type provides a low-level interface to time zone information[.](#info.local-1.sentence-1)
|
||
|
||
Typical conversions from local_time to sys_time will use this class implicitly, not explicitly[.](#info.local-1.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[2](#info.local-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9344)
|
||
|
||
Describes the result of converting a local_time to a sys_time as follows:
|
||
|
||
- [(2.1)](#info.local-2.1)
|
||
|
||
When a local_time to sys_time conversion is unique,result == unique,first will be filled out with the correct sys_info,
|
||
andsecond will be zero-initialized[.](#info.local-2.1.sentence-1)
|
||
|
||
- [(2.2)](#info.local-2.2)
|
||
|
||
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,
|
||
andsecond will be filled out with the sys_info that begins just after the local_time[.](#info.local-2.2.sentence-1)
|
||
|
||
- [(2.3)](#info.local-2.3)
|
||
|
||
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,
|
||
andsecond will be filled out with the sys_info that starts just before the local_time[.](#info.local-2.3.sentence-1)
|
||
|
||
[ð](#lib:operator%3c%3c,local_info)
|
||
|
||
`template<class charT, class traits>
|
||
basic_ostream<charT, traits>&
|
||
operator<<(basic_ostream<charT, traits>& os, const local_info& r);
|
||
`
|
||
|
||
[3](#info.local-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9382)
|
||
|
||
*Effects*: Streams out the local_info object r in an unspecified format[.](#info.local-3.sentence-1)
|
||
|
||
[4](#info.local-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9386)
|
||
|
||
*Returns*: os[.](#info.local-4.sentence-1)
|
||
|
||
### [30.11.5](#timezone) Class time_zone [[time.zone.timezone]](time.zone.timezone)
|
||
|
||
#### [30.11.5.1](#overview) Overview [[time.zone.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; };}
|
||
|
||
[1](#overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9425)
|
||
|
||
A time_zone represents all time zone transitions
|
||
for a specific geographic area[.](#overview-1.sentence-1)
|
||
|
||
time_zone construction is unspecified,
|
||
and performed as part of database initialization[.](#overview-1.sentence-2)
|
||
|
||
[*Note [1](#overview-note-1)*:
|
||
|
||
const time_zone objects can be accessed
|
||
via functions such as locate_zone[.](#overview-1.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
#### [30.11.5.2](#members) Member functions [[time.zone.members]](time.zone.members)
|
||
|
||
[ð](#lib:name,time_zone)
|
||
|
||
`string_view name() const noexcept;
|
||
`
|
||
|
||
[1](#members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9443)
|
||
|
||
*Returns*: The name of the time_zone[.](#members-1.sentence-1)
|
||
|
||
[2](#members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9447)
|
||
|
||
[*Example [1](#members-example-1)*:
|
||
|
||
"America/New_York"[.](#members-2.sentence-1)
|
||
|
||
â *end example*]
|
||
|
||
[ð](#lib:get_info,time_zone)
|
||
|
||
`template<class Duration>
|
||
sys_info get_info(const sys_time<Duration>& st) const;
|
||
`
|
||
|
||
[3](#members-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9460)
|
||
|
||
*Returns*: A sys_info i for whichst is in the range [i.begin, i.end)[.](#members-3.sentence-1)
|
||
|
||
[ð](#lib:get_info,time_zone_)
|
||
|
||
`template<class Duration>
|
||
local_info get_info(const local_time<Duration>& tp) const;
|
||
`
|
||
|
||
[4](#members-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9473)
|
||
|
||
*Returns*: A local_info for tp[.](#members-4.sentence-1)
|
||
|
||
[ð](#lib:to_sys,time_zone)
|
||
|
||
`template<class Duration>
|
||
sys_time<common_type_t<Duration, seconds>>
|
||
to_sys(const local_time<Duration>& tp) const;
|
||
`
|
||
|
||
[5](#members-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9486)
|
||
|
||
*Returns*: A sys_time that is at least as fine as seconds,
|
||
and will be finer if the argument tp has finer precision[.](#members-5.sentence-1)
|
||
|
||
This sys_time is the UTC equivalent of tp according to the rules of this time_zone[.](#members-5.sentence-2)
|
||
|
||
[6](#members-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9493)
|
||
|
||
*Throws*: If the conversion from tp to a sys_time is ambiguous,
|
||
throws ambiguous_local_time[.](#members-6.sentence-1)
|
||
|
||
If the tp represents a non-existent time between two UTC time_points,
|
||
throws nonexistent_local_time[.](#members-6.sentence-2)
|
||
|
||
[ð](#lib:to_sys,time_zone_)
|
||
|
||
`template<class Duration>
|
||
sys_time<common_type_t<Duration, seconds>>
|
||
to_sys(const local_time<Duration>& tp, choose z) const;
|
||
`
|
||
|
||
[7](#members-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9509)
|
||
|
||
*Returns*: A sys_time that is at least as fine as seconds,
|
||
and will be finer if the argument tp has finer precision[.](#members-7.sentence-1)
|
||
|
||
This sys_time is the UTC equivalent of tp according to the rules of this time_zone[.](#members-7.sentence-2)
|
||
|
||
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[.](#members-7.sentence-3)
|
||
|
||
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[.](#members-7.sentence-4)
|
||
|
||
[ð](#lib:to_local,time_zone)
|
||
|
||
`template<class Duration>
|
||
local_time<common_type_t<Duration, seconds>>
|
||
to_local(const sys_time<Duration>& tp) const;
|
||
`
|
||
|
||
[8](#members-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9531)
|
||
|
||
*Returns*: The local_time associated with tp and this time_zone[.](#members-8.sentence-1)
|
||
|
||
#### [30.11.5.3](#nonmembers) Non-member functions [[time.zone.nonmembers]](time.zone.nonmembers)
|
||
|
||
[ð](#lib:operator==,time_zone)
|
||
|
||
`bool operator==(const time_zone& x, const time_zone& y) noexcept;
|
||
`
|
||
|
||
[1](#nonmembers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9544)
|
||
|
||
*Returns*: x.name() == y.name()[.](#nonmembers-1.sentence-1)
|
||
|
||
[ð](#lib:operator%3c=%3e,time_zone)
|
||
|
||
`strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept;
|
||
`
|
||
|
||
[2](#nonmembers-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9555)
|
||
|
||
*Returns*: x.name() <=> y.name()[.](#nonmembers-2.sentence-1)
|
||
|
||
### [30.11.6](#zonedtraits) Class template zoned_traits [[time.zone.zonedtraits]](time.zone.zonedtraits)
|
||
|
||
namespace std::chrono {template<class T> struct zoned_traits {};}
|
||
|
||
[1](#zonedtraits-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9569)
|
||
|
||
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[.](#zonedtraits-1.sentence-1)
|
||
|
||
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); };}
|
||
|
||
[ð](#lib:default_zone,zoned_traits%3cconst_time_zone*%3e)
|
||
|
||
`static const time_zone* default_zone();
|
||
`
|
||
|
||
[2](#zonedtraits-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9590)
|
||
|
||
*Returns*: std::chrono::locate_zone("UTC")[.](#zonedtraits-2.sentence-1)
|
||
|
||
[ð](#lib:locate_zone,zoned_traits%3cconst_time_zone*%3e)
|
||
|
||
`static const time_zone* locate_zone(string_view name);
|
||
`
|
||
|
||
[3](#zonedtraits-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9601)
|
||
|
||
*Returns*: std::chrono::locate_zone(name)[.](#zonedtraits-3.sentence-1)
|
||
|
||
### [30.11.7](#zonedtime) Class template zoned_time [[time.zone.zonedtime]](time.zone.zonedtime)
|
||
|
||
#### [30.11.7.1](#zonedtime.overview) Overview [[time.zone.zonedtime.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>>;}
|
||
|
||
[1](#zonedtime.overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9701)
|
||
|
||
zoned_time represents a logical pairing of
|
||
a time_zone and a time_point with precision Duration[.](#zonedtime.overview-1.sentence-1)
|
||
|
||
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[.](#zonedtime.overview-1.sentence-2)
|
||
|
||
[2](#zonedtime.overview-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9709)
|
||
|
||
If Duration is not a specialization of chrono::duration,
|
||
the program is ill-formed[.](#zonedtime.overview-2.sentence-1)
|
||
|
||
[3](#zonedtime.overview-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9713)
|
||
|
||
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]](over.match.class.deduct "12.2.2.9 Class template argument deduction"))[.](#zonedtime.overview-3.sentence-1)
|
||
|
||
#### [30.11.7.2](#zonedtime.ctor) Constructors [[time.zone.zonedtime.ctor]](time.zone.zonedtime.ctor)
|
||
|
||
[ð](#lib:zoned_time,constructor)
|
||
|
||
`zoned_time();
|
||
`
|
||
|
||
[1](#zonedtime.ctor-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9727)
|
||
|
||
*Constraints*: traits::default_zone() is a well-formed expression[.](#zonedtime.ctor-1.sentence-1)
|
||
|
||
[2](#zonedtime.ctor-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9731)
|
||
|
||
*Effects*: Initializes zone_ with traits::default_zone() and
|
||
default constructs tp_[.](#zonedtime.ctor-2.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:2)
|
||
|
||
`zoned_time(const sys_time<Duration>& st);
|
||
`
|
||
|
||
[3](#zonedtime.ctor-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9742)
|
||
|
||
*Constraints*: traits::default_zone() is a well-formed expression[.](#zonedtime.ctor-3.sentence-1)
|
||
|
||
[4](#zonedtime.ctor-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9746)
|
||
|
||
*Effects*: Initializes zone_ with traits::default_zone() and tp_ with st[.](#zonedtime.ctor-4.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:3)
|
||
|
||
`explicit zoned_time(TimeZonePtr z);
|
||
`
|
||
|
||
[5](#zonedtime.ctor-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9756)
|
||
|
||
*Preconditions*: z refers to a time zone[.](#zonedtime.ctor-5.sentence-1)
|
||
|
||
[6](#zonedtime.ctor-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9760)
|
||
|
||
*Effects*: Initializes zone_ with std::move(z) and
|
||
default constructs tp_[.](#zonedtime.ctor-6.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:4)
|
||
|
||
`explicit zoned_time(string_view name);
|
||
`
|
||
|
||
[7](#zonedtime.ctor-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9771)
|
||
|
||
*Constraints*: traits::locate_zone(string_view{}) is a well-formed expression andzoned_time is constructible from the return type of traits::locate_zone(string_view{})[.](#zonedtime.ctor-7.sentence-1)
|
||
|
||
[8](#zonedtime.ctor-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9776)
|
||
|
||
*Effects*: Initializes zone_ with traits::locate_zone(name) and
|
||
default constructs tp_[.](#zonedtime.ctor-8.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:5)
|
||
|
||
`template<class Duration2>
|
||
zoned_time(const zoned_time<Duration2, TimeZonePtr>& y);
|
||
`
|
||
|
||
[9](#zonedtime.ctor-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9788)
|
||
|
||
*Constraints*: is_convertible_v<sys_time<Duration2>, sys_time<Duration>> is true[.](#zonedtime.ctor-9.sentence-1)
|
||
|
||
[10](#zonedtime.ctor-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9792)
|
||
|
||
*Effects*: Initializes zone_ with y.zone_ and tp_ with y.tp_[.](#zonedtime.ctor-10.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:6)
|
||
|
||
`zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
|
||
`
|
||
|
||
[11](#zonedtime.ctor-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9802)
|
||
|
||
*Preconditions*: z refers to a time zone[.](#zonedtime.ctor-11.sentence-1)
|
||
|
||
[12](#zonedtime.ctor-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9806)
|
||
|
||
*Effects*: Initializes zone_ with std::move(z) and tp_ with st[.](#zonedtime.ctor-12.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:7)
|
||
|
||
`zoned_time(string_view name, const sys_time<Duration>& st);
|
||
`
|
||
|
||
[13](#zonedtime.ctor-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9816)
|
||
|
||
*Constraints*: zoned_time is constructible from the return type of traits::locate_zone(name) and st[.](#zonedtime.ctor-13.sentence-1)
|
||
|
||
[14](#zonedtime.ctor-14)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9820)
|
||
|
||
*Effects*: Equivalent to construction with {traits::locate_zone(name), st}[.](#zonedtime.ctor-14.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:8)
|
||
|
||
`zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
|
||
`
|
||
|
||
[15](#zonedtime.ctor-15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9830)
|
||
|
||
*Constraints*: is_convertible_v<decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{})),
|
||
sys_time<duration>> is true[.](#zonedtime.ctor-15.sentence-1)
|
||
|
||
[16](#zonedtime.ctor-16)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9839)
|
||
|
||
*Preconditions*: z refers to a time zone[.](#zonedtime.ctor-16.sentence-1)
|
||
|
||
[17](#zonedtime.ctor-17)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9843)
|
||
|
||
*Effects*: Initializes zone_ with std::move(z) and tp_ with zone_->to_sys(tp)[.](#zonedtime.ctor-17.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:9)
|
||
|
||
`zoned_time(string_view name, const local_time<Duration>& tp);
|
||
`
|
||
|
||
[18](#zonedtime.ctor-18)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9853)
|
||
|
||
*Constraints*: zoned_time is constructible from the return type of traits::locate_zone(name) and tp[.](#zonedtime.ctor-18.sentence-1)
|
||
|
||
[19](#zonedtime.ctor-19)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9857)
|
||
|
||
*Effects*: Equivalent to construction with {traits::locate_zone(name), tp}[.](#zonedtime.ctor-19.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:10)
|
||
|
||
`zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
|
||
`
|
||
|
||
[20](#zonedtime.ctor-20)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9867)
|
||
|
||
*Constraints*: is_convertible_v<decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{}, choose::earliest)),
|
||
sys_time<duration>> is true[.](#zonedtime.ctor-20.sentence-1)
|
||
|
||
[21](#zonedtime.ctor-21)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9876)
|
||
|
||
*Preconditions*: z refers to a time zone[.](#zonedtime.ctor-21.sentence-1)
|
||
|
||
[22](#zonedtime.ctor-22)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9880)
|
||
|
||
*Effects*: Initializes zone_ with std::move(z) and tp_ with zone_->to_sys(tp, c)[.](#zonedtime.ctor-22.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:11)
|
||
|
||
`zoned_time(string_view name, const local_time<Duration>& tp, choose c);
|
||
`
|
||
|
||
[23](#zonedtime.ctor-23)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9890)
|
||
|
||
*Constraints*: zoned_time is constructible from
|
||
the return type of traits::locate_zone(name), local_time<Duration>, and choose[.](#zonedtime.ctor-23.sentence-1)
|
||
|
||
[24](#zonedtime.ctor-24)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9895)
|
||
|
||
*Effects*: Equivalent to construction with {traits::locate_zone(name), tp, c}[.](#zonedtime.ctor-24.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:12)
|
||
|
||
`template<class Duration2, class TimeZonePtr2>
|
||
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y);
|
||
`
|
||
|
||
[25](#zonedtime.ctor-25)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9906)
|
||
|
||
*Constraints*: is_convertible_v<sys_time<Duration2>, sys_time<Duration>> is true[.](#zonedtime.ctor-25.sentence-1)
|
||
|
||
[26](#zonedtime.ctor-26)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9910)
|
||
|
||
*Preconditions*: z refers to a valid time zone[.](#zonedtime.ctor-26.sentence-1)
|
||
|
||
[27](#zonedtime.ctor-27)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9914)
|
||
|
||
*Effects*: Initializes zone_ with std::move(z) and tp_ with y.tp_[.](#zonedtime.ctor-27.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:13)
|
||
|
||
`template<class Duration2, class TimeZonePtr2>
|
||
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y, choose);
|
||
`
|
||
|
||
[28](#zonedtime.ctor-28)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9925)
|
||
|
||
*Constraints*: is_convertible_v<sys_time<Duration2>, sys_time<Duration>> is true[.](#zonedtime.ctor-28.sentence-1)
|
||
|
||
[29](#zonedtime.ctor-29)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9929)
|
||
|
||
*Preconditions*: z refers to a valid time zone[.](#zonedtime.ctor-29.sentence-1)
|
||
|
||
[30](#zonedtime.ctor-30)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9933)
|
||
|
||
*Effects*: Equivalent to construction with {z, y}[.](#zonedtime.ctor-30.sentence-1)
|
||
|
||
[31](#zonedtime.ctor-31)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9937)
|
||
|
||
[*Note [1](#zonedtime.ctor-note-1)*:
|
||
|
||
The choose parameter has no effect[.](#zonedtime.ctor-31.sentence-1)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:14)
|
||
|
||
`template<class Duration2, class TimeZonePtr2>
|
||
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y);
|
||
`
|
||
|
||
[32](#zonedtime.ctor-32)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9949)
|
||
|
||
*Constraints*: zoned_time is constructible from
|
||
the return type of traits::locate_zone(name) and
|
||
the type zoned_time<Duration2, TimeZonePtr2>[.](#zonedtime.ctor-32.sentence-1)
|
||
|
||
[33](#zonedtime.ctor-33)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9955)
|
||
|
||
*Effects*: Equivalent to construction with {traits::locate_zone(name), y}[.](#zonedtime.ctor-33.sentence-1)
|
||
|
||
[ð](#zonedtime.ctor-itemdecl:15)
|
||
|
||
`template<class Duration2, class TimeZonePtr2>
|
||
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y, choose c);
|
||
`
|
||
|
||
[34](#zonedtime.ctor-34)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9966)
|
||
|
||
*Constraints*: zoned_time is constructible from
|
||
the return type of traits::locate_zone(name),
|
||
the type zoned_time<Duration2, TimeZonePtr2>, and
|
||
the type choose[.](#zonedtime.ctor-34.sentence-1)
|
||
|
||
[35](#zonedtime.ctor-35)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9973)
|
||
|
||
*Effects*: Equivalent to construction with {traits::locate_zone(name), y, c}[.](#zonedtime.ctor-35.sentence-1)
|
||
|
||
[36](#zonedtime.ctor-36)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9977)
|
||
|
||
[*Note [2](#zonedtime.ctor-note-2)*:
|
||
|
||
The choose parameter has no effect[.](#zonedtime.ctor-36.sentence-1)
|
||
|
||
â *end note*]
|
||
|
||
#### [30.11.7.3](#zonedtime.members) Member functions [[time.zone.zonedtime.members]](time.zone.zonedtime.members)
|
||
|
||
[ð](#lib:operator=,zoned_time)
|
||
|
||
`zoned_time& operator=(const sys_time<Duration>& st);
|
||
`
|
||
|
||
[1](#zonedtime.members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9992)
|
||
|
||
*Effects*: After assignment, get_sys_time() == st[.](#zonedtime.members-1.sentence-1)
|
||
|
||
This assignment has no effect on the return value of get_time_zone()[.](#zonedtime.members-1.sentence-2)
|
||
|
||
[2](#zonedtime.members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9997)
|
||
|
||
*Returns*: *this[.](#zonedtime.members-2.sentence-1)
|
||
|
||
[ð](#lib:operator=,zoned_time_)
|
||
|
||
`zoned_time& operator=(const local_time<Duration>& lt);
|
||
`
|
||
|
||
[3](#zonedtime.members-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10008)
|
||
|
||
*Effects*: After assignment, get_local_time() == lt[.](#zonedtime.members-3.sentence-1)
|
||
|
||
This assignment has no effect on the return value of get_time_zone()[.](#zonedtime.members-3.sentence-2)
|
||
|
||
[4](#zonedtime.members-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10013)
|
||
|
||
*Returns*: *this[.](#zonedtime.members-4.sentence-1)
|
||
|
||
[ð](#lib:operator_sys_time,zoned_time)
|
||
|
||
`operator sys_time<duration>() const;
|
||
`
|
||
|
||
[5](#zonedtime.members-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10024)
|
||
|
||
*Returns*: get_sys_time()[.](#zonedtime.members-5.sentence-1)
|
||
|
||
[ð](#lib:operator_local_time,zoned_time)
|
||
|
||
`explicit operator local_time<duration>() const;
|
||
`
|
||
|
||
[6](#zonedtime.members-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10035)
|
||
|
||
*Returns*: get_local_time()[.](#zonedtime.members-6.sentence-1)
|
||
|
||
[ð](#lib:get_time_zone,zoned_time)
|
||
|
||
`TimeZonePtr get_time_zone() const;
|
||
`
|
||
|
||
[7](#zonedtime.members-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10046)
|
||
|
||
*Returns*: zone_[.](#zonedtime.members-7.sentence-1)
|
||
|
||
[ð](#lib:get_local_time,zoned_time)
|
||
|
||
`local_time<duration> get_local_time() const;
|
||
`
|
||
|
||
[8](#zonedtime.members-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10057)
|
||
|
||
*Returns*: zone_->to_local(tp_)[.](#zonedtime.members-8.sentence-1)
|
||
|
||
[ð](#lib:get_sys_time,zoned_time)
|
||
|
||
`sys_time<duration> get_sys_time() const;
|
||
`
|
||
|
||
[9](#zonedtime.members-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10068)
|
||
|
||
*Returns*: tp_[.](#zonedtime.members-9.sentence-1)
|
||
|
||
[ð](#lib:get_info,zoned_time)
|
||
|
||
`sys_info get_info() const;
|
||
`
|
||
|
||
[10](#zonedtime.members-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10079)
|
||
|
||
*Returns*: zone_->get_info(tp_)[.](#zonedtime.members-10.sentence-1)
|
||
|
||
#### [30.11.7.4](#zonedtime.nonmembers) Non-member functions [[time.zone.zonedtime.nonmembers]](time.zone.zonedtime.nonmembers)
|
||
|
||
[ð](#lib:operator==,zoned_time)
|
||
|
||
`template<class Duration1, class Duration2, class TimeZonePtr>
|
||
bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
|
||
const zoned_time<Duration2, TimeZonePtr>& y);
|
||
`
|
||
|
||
[1](#zonedtime.nonmembers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10094)
|
||
|
||
*Returns*: x.zone_ == y.zone_ && x.tp_ == y.tp_[.](#zonedtime.nonmembers-1.sentence-1)
|
||
|
||
[ð](#lib:operator%3c%3c,zoned_time)
|
||
|
||
`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);
|
||
`
|
||
|
||
[2](#zonedtime.nonmembers-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10108)
|
||
|
||
*Effects*: Equivalent to:return os << format(os.getloc(), *STATICALLY-WIDEN*<charT>("{:L%F %T %Z}"), t);
|
||
|
||
### [30.11.8](#leap) Class leap_second [[time.zone.leap]](time.zone.leap)
|
||
|
||
#### [30.11.8.1](#leap.overview) Overview [[time.zone.leap.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](#leap.overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10136)
|
||
|
||
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[.](#leap.overview-1.sentence-1)
|
||
|
||
[2](#leap.overview-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10141)
|
||
|
||
[*Example [1](#leap.overview-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](#leap.members) Member functions [[time.zone.leap.members]](time.zone.leap.members)
|
||
|
||
[ð](#lib:date,leap_second)
|
||
|
||
`constexpr sys_seconds date() const noexcept;
|
||
`
|
||
|
||
[1](#leap.members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10189)
|
||
|
||
*Returns*: The date and time at which the leap second was inserted[.](#leap.members-1.sentence-1)
|
||
|
||
[ð](#lib:value,leap_second)
|
||
|
||
`constexpr seconds value() const noexcept;
|
||
`
|
||
|
||
[2](#leap.members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10200)
|
||
|
||
*Returns*: +1s to indicate a positive leap second or-1s to indicate a negative leap second[.](#leap.members-2.sentence-1)
|
||
|
||
[*Note [1](#leap.members-note-1)*:
|
||
|
||
All leap seconds inserted up through 2022 were positive leap seconds[.](#leap.members-2.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
#### [30.11.8.3](#leap.nonmembers) Non-member functions [[time.zone.leap.nonmembers]](time.zone.leap.nonmembers)
|
||
|
||
[ð](#lib:operator==,leap_second)
|
||
|
||
`constexpr bool operator==(const leap_second& x, const leap_second& y) noexcept;
|
||
`
|
||
|
||
[1](#leap.nonmembers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10217)
|
||
|
||
*Returns*: x.date() == y.date()[.](#leap.nonmembers-1.sentence-1)
|
||
|
||
[ð](#lib:operator%3c=%3e,leap_second)
|
||
|
||
`constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y) noexcept;
|
||
`
|
||
|
||
[2](#leap.nonmembers-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10228)
|
||
|
||
*Returns*: x.date() <=> y.date()[.](#leap.nonmembers-2.sentence-1)
|
||
|
||
[ð](#lib:operator==,leap_second_)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
||
`
|
||
|
||
[3](#leap.nonmembers-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10241)
|
||
|
||
*Returns*: x.date() == y[.](#leap.nonmembers-3.sentence-1)
|
||
|
||
[ð](#lib:operator%3c,leap_second)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator<(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
||
`
|
||
|
||
[4](#leap.nonmembers-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10254)
|
||
|
||
*Returns*: x.date() < y[.](#leap.nonmembers-4.sentence-1)
|
||
|
||
[ð](#lib:operator%3c,leap_second_)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator<(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
||
`
|
||
|
||
[5](#leap.nonmembers-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10267)
|
||
|
||
*Returns*: x < y.date()[.](#leap.nonmembers-5.sentence-1)
|
||
|
||
[ð](#lib:operator%3e,leap_second)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator>(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
||
`
|
||
|
||
[6](#leap.nonmembers-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10280)
|
||
|
||
*Returns*: y < x[.](#leap.nonmembers-6.sentence-1)
|
||
|
||
[ð](#lib:operator%3e,leap_second_)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator>(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
||
`
|
||
|
||
[7](#leap.nonmembers-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10293)
|
||
|
||
*Returns*: y < x[.](#leap.nonmembers-7.sentence-1)
|
||
|
||
[ð](#lib:operator%3c=,leap_second)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
||
`
|
||
|
||
[8](#leap.nonmembers-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10306)
|
||
|
||
*Returns*: !(y < x)[.](#leap.nonmembers-8.sentence-1)
|
||
|
||
[ð](#lib:operator%3c=,leap_second_)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
||
`
|
||
|
||
[9](#leap.nonmembers-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10319)
|
||
|
||
*Returns*: !(y < x)[.](#leap.nonmembers-9.sentence-1)
|
||
|
||
[ð](#lib:operator%3e=,leap_second)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
||
`
|
||
|
||
[10](#leap.nonmembers-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10332)
|
||
|
||
*Returns*: !(x < y)[.](#leap.nonmembers-10.sentence-1)
|
||
|
||
[ð](#lib:operator%3e=,leap_second_)
|
||
|
||
`template<class Duration>
|
||
constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
||
`
|
||
|
||
[11](#leap.nonmembers-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10345)
|
||
|
||
*Returns*: !(x < y)[.](#leap.nonmembers-11.sentence-1)
|
||
|
||
[ð](#lib:operator%3c=%3e,leap_second_)
|
||
|
||
`template<class Duration>
|
||
requires [three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4 Concept three_way_comparable [cmp.concept]")<sys_seconds, sys_time<Duration>>
|
||
constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
||
`
|
||
|
||
[12](#leap.nonmembers-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10359)
|
||
|
||
*Returns*: x.date() <=> y[.](#leap.nonmembers-12.sentence-1)
|
||
|
||
### [30.11.9](#link) Class time_zone_link [[time.zone.link]](time.zone.link)
|
||
|
||
#### [30.11.9.1](#link.overview) Overview [[time.zone.link.overview]](time.zone.link.overview)
|
||
|
||
namespace std::chrono {class time_zone_link {public: time_zone_link(time_zone_link&&) = default;
|
||
time_zone_link& operator=(time_zone_link&&) = default; // unspecified additional constructors string_view name() const noexcept;
|
||
string_view target() const noexcept; };}
|
||
|
||
[1](#link.overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10384)
|
||
|
||
A time_zone_link specifies an alternative name for a time_zone[.](#link.overview-1.sentence-1)
|
||
|
||
time_zone_links are constructed when the time zone database is initialized[.](#link.overview-1.sentence-2)
|
||
|
||
#### [30.11.9.2](#link.members) Member functions [[time.zone.link.members]](time.zone.link.members)
|
||
|
||
[ð](#lib:name,time_zone_link)
|
||
|
||
`string_view name() const noexcept;
|
||
`
|
||
|
||
[1](#link.members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10396)
|
||
|
||
*Returns*: The alternative name for the time zone[.](#link.members-1.sentence-1)
|
||
|
||
[ð](#lib:target,time_zone_link)
|
||
|
||
`string_view target() const noexcept;
|
||
`
|
||
|
||
[2](#link.members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10407)
|
||
|
||
*Returns*: The name of the time_zone for which
|
||
this time_zone_link provides an alternative name[.](#link.members-2.sentence-1)
|
||
|
||
#### [30.11.9.3](#link.nonmembers) Non-member functions [[time.zone.link.nonmembers]](time.zone.link.nonmembers)
|
||
|
||
[ð](#lib:operator==,time_zone_link)
|
||
|
||
`bool operator==(const time_zone_link& x, const time_zone_link& y) noexcept;
|
||
`
|
||
|
||
[1](#link.nonmembers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10421)
|
||
|
||
*Returns*: x.name() == y.name()[.](#link.nonmembers-1.sentence-1)
|
||
|
||
[ð](#lib:operator%3c=%3e,time_zone_link)
|
||
|
||
`strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y) noexcept;
|
||
`
|
||
|
||
[2](#link.nonmembers-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L10432)
|
||
|
||
*Returns*: x.name() <=> y.name()[.](#link.nonmembers-2.sentence-1)
|