Updated Examples and Recipes (markdown)

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

@@ -1614,13 +1614,14 @@ 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):
#include <iostream>
#include <sstream>
#include <string>
#include "tz.h"
```c++
#include <iostream>
#include <sstream>
#include <string>
#include "tz.h"
int main()
{
int main()
{
using namespace std;
using namespace date;
@@ -1638,7 +1639,8 @@ 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,13 +1652,14 @@ 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:
#include <iostream>
#include <sstream>
#include <string>
#include "tz.h"
```c++
#include <iostream>
#include <sstream>
#include <string>
#include "tz.h"
int main()
{
int main()
{
using namespace std;
using namespace date;
@@ -1702,7 +1705,8 @@ 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").