From Jason Turner

[time.zone.exception]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_8nkl4p7/{from.md → to.md} +129 -0
tmp/tmp_8nkl4p7/{from.md → to.md} RENAMED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Exception classes <a id="time.zone.exception">[[time.zone.exception]]</a>
2
+
3
+ #### Class `nonexistent_local_time` <a id="time.zone.exception.nonexist">[[time.zone.exception.nonexist]]</a>
4
+
5
+ ``` cpp
6
+ namespace std::chrono {
7
+ class nonexistent_local_time : public runtime_error {
8
+ public:
9
+ template<class Duration>
10
+ nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
11
+ };
12
+ }
13
+ ```
14
+
15
+ `nonexistent_local_time` is thrown when an attempt is made to convert a
16
+ non-existent `local_time` to a `sys_time` without specifying
17
+ `choose::earliest` or `choose::latest`.
18
+
19
+ ``` cpp
20
+ template<class Duration>
21
+ nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
22
+ ```
23
+
24
+ *Preconditions:* `i.result == local_info::nonexistent` is `true`.
25
+
26
+ *Effects:* Initializes the base class with a sequence of `char`
27
+ equivalent to that produced by `os.str()` initialized as shown below:
28
+
29
+ ``` cpp
30
+ ostringstream os;
31
+ os << tp << " is in a gap between\n"
32
+ << local_seconds{i.first.end.time_since_epoch()} + i.first.offset << ' '
33
+ << i.first.abbrev << " and\n"
34
+ << local_seconds{i.second.begin.time_since_epoch()} + i.second.offset << ' '
35
+ << i.second.abbrev
36
+ << " which are both equivalent to\n"
37
+ << i.first.end << " UTC";
38
+ ```
39
+
40
+ [*Example 1*:
41
+
42
+ ``` cpp
43
+ #include <chrono>
44
+ #include <iostream>
45
+
46
+ int main() {
47
+ using namespace std::chrono;
48
+ try {
49
+ auto zt = zoned_time{"America/New_York",
50
+ local_days{Sunday[2]/March/2016} + 2h + 30min};
51
+ } catch (const nonexistent_local_time& e) {
52
+ std::cout << e.what() << '\n';
53
+ }
54
+ }
55
+ ```
56
+
57
+ Produces the output:
58
+
59
+ ``` text
60
+ 2016-03-13 02:30:00 is in a gap between
61
+ 2016-03-13 02:00:00 EST and
62
+ 2016-03-13 03:00:00 EDT which are both equivalent to
63
+ 2016-03-13 07:00:00 UTC
64
+ ```
65
+
66
+ — *end example*]
67
+
68
+ #### Class `ambiguous_local_time` <a id="time.zone.exception.ambig">[[time.zone.exception.ambig]]</a>
69
+
70
+ ``` cpp
71
+ namespace std::chrono {
72
+ class ambiguous_local_time : public runtime_error {
73
+ public:
74
+ template<class Duration>
75
+ ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
76
+ };
77
+ }
78
+ ```
79
+
80
+ `ambiguous_local_time` is thrown when an attempt is made to convert an
81
+ ambiguous `local_time` to a `sys_time` without specifying
82
+ `choose::earliest` or `choose::latest`.
83
+
84
+ ``` cpp
85
+ template<class Duration>
86
+ ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
87
+ ```
88
+
89
+ *Preconditions:* `i.result == local_info::ambiguous` is `true`.
90
+
91
+ *Effects:* Initializes the base class with a sequence of `char`
92
+ equivalent to that produced by `os.str()` initialized as shown below:
93
+
94
+ ``` cpp
95
+ ostringstream os;
96
+ os << tp << " is ambiguous. It could be\n"
97
+ << tp << ' ' << i.first.abbrev << " == "
98
+ << tp - i.first.offset << " UTC or\n"
99
+ << tp << ' ' << i.second.abbrev << " == "
100
+ << tp - i.second.offset << " UTC";
101
+ ```
102
+
103
+ [*Example 1*:
104
+
105
+ ``` cpp
106
+ #include <chrono>
107
+ #include <iostream>
108
+
109
+ int main() {
110
+ using namespace std::chrono;
111
+ try {
112
+ auto zt = zoned_time{"America/New_York",
113
+ local_days{Sunday[1]/November/2016} + 1h + 30min};
114
+ } catch (const ambiguous_local_time& e) {
115
+ std::cout << e.what() << '\n';
116
+ }
117
+ }
118
+ ```
119
+
120
+ Produces the output:
121
+
122
+ ``` text
123
+ 2016-11-06 01:30:00 is ambiguous. It could be
124
+ 2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or
125
+ 2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC
126
+ ```
127
+
128
+ — *end example*]
129
+