mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-04 21:24:26 +02:00
Updated Examples and Recipes (markdown)
@@ -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):
|
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 <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#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.
|
// 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,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:
|
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 <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#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.
|
// 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