From 99383f506682b78f2f6fef37ac267e84669dc294 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 6 Aug 2016 20:49:24 -0400 Subject: [PATCH] Updated Examples and Recipes (markdown) --- Examples-and-Recipes.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Examples-and-Recipes.md b/Examples-and-Recipes.md index 5927fa0..ffa6097 100644 --- a/Examples-and-Recipes.md +++ b/Examples-and-Recipes.md @@ -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) - [Set simultaneous meeting in two different time zones](#meeting) - [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 `y/m/d h:m:s` components from a `time_point`](#components_to_time_point) - [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. + +### 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 + + int + main() + { + std::cout << date::get_tzdb().version << '\n'; + } + +As I write this, the output is: + + 2016f + ### Obtaining a `time_point` from `y/m/d h:m:s` components (by [ecorm](https://github.com/ecorm))