mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-04 21:24:26 +02:00
Updated Examples and Recipes (markdown)
@@ -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):
|
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>
|
```c++
|
||||||
#include <sstream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <sstream>
|
||||||
#include "tz.h"
|
#include <string>
|
||||||
|
#include "tz.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace date;
|
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.
|
// 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';
|
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:
|
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>
|
```c++
|
||||||
#include <sstream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <sstream>
|
||||||
#include "tz.h"
|
#include <string>
|
||||||
|
#include "tz.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace date;
|
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.
|
// 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';
|
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").
|
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").
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user