Updated Examples and Recipes (markdown)

Howard Hinnant
2017-04-17 13:33:52 -04:00
parent 8fd308e2d7
commit 988ec745b2

@@ -1614,6 +1614,7 @@ and then the solution is simple. To convert PST to -08:00 is in general non-triv
Once we have a string of form 2), give this sample code a try (thank you [Aaron](https://github.com/ahn6) who provided the draft):
```c++
#include <iostream>
#include <sstream>
#include <string>
@@ -1639,6 +1640,7 @@ Once we have a string of form 2), give this sample code a try (thank you [Aaron]
// This will output America/Los_Angeles, because US/Pacific is an alias of it.
cout << format("%F %T %Ez", zt) << ' ' << zt.get_time_zone()->name() << '\n';
}
```
***
@@ -1650,6 +1652,7 @@ There is now functionality to parse the original format:
And check if the time zone abbreviation is consistent, and in the ambiguous case, use the time zone abbreviation to disambiguate the time stamp:
```c++
#include <iostream>
#include <sstream>
#include <string>
@@ -1703,6 +1706,7 @@ And check if the time zone abbreviation is consistent, and in the ambiguous case
// This will output America/Los_Angeles, because US/Pacific is an alias of it.
cout << format("%F %T %Ez", zt) << ' ' << zt.get_time_zone()->name() << '\n';
}
```
This involves getting the `local_info` structure from the `time_zone` for that `local_time`. The `local_info` will have all of the information about that `time_zone/local_time` combination, including whether there is a unique mapping to UTC, a non-existing mapping (as in the gap created by "spring forward"), or an ambiguous mapping (created by a local time occurring twice during a "fall back").