Updated Examples and Recipes (markdown)

Howard Hinnant
2016-08-06 20:49:24 -04:00
parent 844b20e436
commit 99383f5066

@@ -6,6 +6,7 @@ This page contains examples and recipes contributed by community members. Feel f
- [Get the current difference between any two arbitrary time zones](#deltatz) - [Get the current difference between any two arbitrary time zones](#deltatz)
- [Set simultaneous meeting in two different time zones](#meeting) - [Set simultaneous meeting in two different time zones](#meeting)
- [Get milliseconds since the local midnight](#since_midnight) - [Get milliseconds since the local midnight](#since_midnight)
- [What is my timezone database version?](#version)
- [Obtaining a `time_point` from `y/m/d h:m:s` components](#time_point_to_components) - [Obtaining a `time_point` from `y/m/d h:m:s` components](#time_point_to_components)
- [Obtaining `y/m/d h:m:s` components from a `time_point`](#components_to_time_point) - [Obtaining `y/m/d h:m:s` components from a `time_point`](#components_to_time_point)
- [Normalizing `y/m/d` when it is `!ok()`](#normalize) - [Normalizing `y/m/d` when it is `!ok()`](#normalize)
@@ -253,6 +254,31 @@ And finally an example just after the Fall transition from daylight saving back
Not only does this library make it easy to write the code to do the desired computation, it also makes it easy to write the test code. Not only does this library make it easy to write the code to do the desired computation, it also makes it easy to write the test code.
<a name="version"></a>
### What is my timezone database version?
(by [Howard Hinnant](https://github.com/HowardHinnant))
Many people may not realize this, but the world's timezone rules are updated _quite often_. In the ten year period [2006 - 2015] the IANA timezone database was updated an average of 12.2 times a year (slightly more than once a month). The year 2015 was a slow one: updated only 7 times. But the 6th version for 2016 was released on July 5th, and events have already changed that will demand another version well before the end of the year.
A few of these updates are bug fixes. But most of them are the result of political changes on the ground: Governments around the world (when taken collectively) routinely change their timezone rules, and often with surprisingly little notice (as little as 3 days). So as computers talk to each other more and more, and trade timestamps, it becomes important for computers to ensure that they are using the same timezone rules so that round trip local timestamps are consistent.
This library can query the installed IANA timezone database for its version number. The version number is a `std::string` consisting of the year, followed by a lower case letter, with `a` signifying the first version for the year (there has yet to be more than 26 versions/year, which would be rather absurd).
Here is how you get the version of the installed IANA timezone database:
#include "tz.h"
#include <iostream>
int
main()
{
std::cout << date::get_tzdb().version << '\n';
}
As I write this, the output is:
2016f
<a name="time_point_to_components"></a> <a name="time_point_to_components"></a>
### Obtaining a `time_point` from `y/m/d h:m:s` components ### Obtaining a `time_point` from `y/m/d h:m:s` components
(by [ecorm](https://github.com/ecorm)) (by [ecorm](https://github.com/ecorm))