From 7d74a91aa3137aae9ac7e958aa898ce9995599a6 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 7 Jul 2016 21:59:21 -0400 Subject: [PATCH] Updated Examples and Recipes (markdown) --- Examples-and-Recipes.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Examples-and-Recipes.md b/Examples-and-Recipes.md index c87901d..ef94db6 100644 --- a/Examples-and-Recipes.md +++ b/Examples-and-Recipes.md @@ -134,16 +134,18 @@ Then just print it out: Obviously you could just as easily specify the meeting in Moscow's time zone and then find the equivalent time in New York: - auto moscow = make_zoned("Europe/Moscow", local_days{jul/7/2016} + 16h); + auto moscow = make_zoned("Europe/Moscow", local_days{7_d/jul/2016} + 16h); auto ny = make_zoned("America/New_York", moscow); -This would result in the exact same output. +This would result in the exact same output. For those paying attention, I reordered the date from m/d/y to d/m/y just to show that I could. The meaning is the same. Sometimes it is convenient to specify the time independent of either timezone. For example this might be some celestial event such as an eclipse. Often such events are recorded in UTC so that people in all time zones can more easily know the correct time. It is just as easy to use UTC for this example: - auto utc = sys_days{jul/7/2016} + 13h; + auto utc = sys_days{2016_y/jul/7} + 13h; auto ny = make_zoned("America/New_York", utc); - auto moscow = make_zoned("Europe/Moscow", utc); + auto moscow = make_zoned("Europe/Moscow", etc); + +I reordered the date to y/m/d just to show that I could. As long as the first unit is unambiguous (`year`, `month` or `day`), the following two are unambiguous (only `y/m/d`, `d/m/y` and `m/d/y` are accepted; all others are rejected at compile time). Instead of `local_days`, `sys_days` is used instead. `sys_days` means UTC (technically it means [Unix Time](https://en.wikipedia.org/wiki/Unix_time) which is a very close approximation to UTC). Then you can construct each `zoned_time` with the UTC time (which has type `sys_time` in this example). You could also construct the second `zoned_time` from the first, just as before: