From Jason Turner

[time.zone.exception.ambig]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp074wczjc/{from.md → to.md} +62 -0
tmp/tmp074wczjc/{from.md → to.md} RENAMED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class `ambiguous_local_time` <a id="time.zone.exception.ambig">[[time.zone.exception.ambig]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::chrono {
5
+ class ambiguous_local_time : public runtime_error {
6
+ public:
7
+ template<class Duration>
8
+ ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
9
+ };
10
+ }
11
+ ```
12
+
13
+ `ambiguous_local_time` is thrown when an attempt is made to convert an
14
+ ambiguous `local_time` to a `sys_time` without specifying
15
+ `choose::earliest` or `choose::latest`.
16
+
17
+ ``` cpp
18
+ template<class Duration>
19
+ ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
20
+ ```
21
+
22
+ *Preconditions:* `i.result == local_info::ambiguous` is `true`.
23
+
24
+ *Effects:* Initializes the base class with a sequence of `char`
25
+ equivalent to that produced by `os.str()` initialized as shown below:
26
+
27
+ ``` cpp
28
+ ostringstream os;
29
+ os << tp << " is ambiguous. It could be\n"
30
+ << tp << ' ' << i.first.abbrev << " == "
31
+ << tp - i.first.offset << " UTC or\n"
32
+ << tp << ' ' << i.second.abbrev << " == "
33
+ << tp - i.second.offset << " UTC";
34
+ ```
35
+
36
+ [*Example 1*:
37
+
38
+ ``` cpp
39
+ #include <chrono>
40
+ #include <iostream>
41
+
42
+ int main() {
43
+ using namespace std::chrono;
44
+ try {
45
+ auto zt = zoned_time{"America/New_York",
46
+ local_days{Sunday[1]/November/2016} + 1h + 30min};
47
+ } catch (const ambiguous_local_time& e) {
48
+ std::cout << e.what() << '\n';
49
+ }
50
+ }
51
+ ```
52
+
53
+ Produces the output:
54
+
55
+ ``` text
56
+ 2016-11-06 01:30:00 is ambiguous. It could be
57
+ 2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or
58
+ 2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC
59
+ ```
60
+
61
+ — *end example*]
62
+