168 lines
5.8 KiB
Markdown
168 lines
5.8 KiB
Markdown
[time.zone.info]
|
||
|
||
# 30 Time library [[time]](./#time)
|
||
|
||
## 30.11 Time zones [[time.zone]](time.zone#info)
|
||
|
||
### 30.11.4 Information classes [time.zone.info]
|
||
|
||
#### [30.11.4.1](#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](#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[.](#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[.](#sys-1.sentence-2)
|
||
|
||
[2](#sys-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9250)
|
||
|
||
[*Note [1](#sys-note-1)*:
|
||
|
||
This type provides a low-level interface to time zone information[.](#sys-2.sentence-1)
|
||
|
||
Typical conversions from sys_time to local_time will use this class implicitly, not explicitly[.](#sys-2.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[3](#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)[.](#sys-3.sentence-1)
|
||
|
||
This information can be used to efficiently iterate the transitions of a time_zone[.](#sys-3.sentence-2)
|
||
|
||
[4](#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[.](#sys-4.sentence-1)
|
||
|
||
The relationship between local_time and sys_time is:offset = local_time - sys_time
|
||
|
||
[5](#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[.](#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[.](#sys-5.sentence-2)
|
||
|
||
However, this information should not be taken as authoritative[.](#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[.](#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)[.](#sys-5.sentence-5)
|
||
|
||
[6](#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[.](#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[.](#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](#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[.](#sys-7.sentence-1)
|
||
|
||
[8](#sys-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9309)
|
||
|
||
*Returns*: os[.](#sys-8.sentence-1)
|
||
|
||
#### [30.11.4.2](#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](#local-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9337)
|
||
|
||
[*Note [1](#local-note-1)*:
|
||
|
||
This type provides a low-level interface to time zone information[.](#local-1.sentence-1)
|
||
|
||
Typical conversions from local_time to sys_time will use this class implicitly, not explicitly[.](#local-1.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[2](#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)](#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[.](#local-2.1.sentence-1)
|
||
|
||
- [(2.2)](#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[.](#local-2.2.sentence-1)
|
||
|
||
- [(2.3)](#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[.](#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](#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[.](#local-3.sentence-1)
|
||
|
||
[4](#local-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L9386)
|
||
|
||
*Returns*: os[.](#local-4.sentence-1)
|