From d9063e5ce18927b58d8d43443d5fce7b7b616ca9 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 21 May 2016 11:34:55 -0400 Subject: [PATCH] Updated Examples and Recipes (markdown) --- Examples-and-Recipes.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Examples-and-Recipes.md b/Examples-and-Recipes.md index ec55dda..ebb759c 100644 --- a/Examples-and-Recipes.md +++ b/Examples-and-Recipes.md @@ -225,12 +225,12 @@ This creates two `year_month` objects and subtracts them. This gives a `std::ch 36 -To include the influence of the day-fields, it is best to convert `d1` and `d2` to `sys_days `s: +To include the influence of the day-fields, it is best to convert `d1` and `d2` to `sys_days`s: auto dp1 = sys_days(d1); auto dp2 = sys_days(d2); -Now we could (for example) subtract the two `sys_days `s, and round the result to the nearest integral month: +Now we could (for example) subtract the two `sys_days`s, and round the result to the nearest integral month: std::cout << round(dp2-dp1).count() << '\n'; @@ -259,11 +259,11 @@ The [ISO week date](https://en.wikipedia.org/wiki/ISO_week_date) is an internati Like ``, you can specify an ISO week date in any of the three orders: y/wn/wd, wd/wn/y, wn/wd/y (big endian, little endian, mixed (american) endian). -Also like ``, you can implicitly convert a ISO week date to `sys_days `, and vice-versa. For convenience, an alias of `date:: sys_days ` exists as `iso_week:: sys_days `: +Also like ``, you can implicitly convert a ISO week date to `sys_days`, and vice-versa. For convenience, an alias of `date:: sys_days ` exists as `iso_week:: sys_days `: iso_week:: sys_days dp = iso_date; -And recall that `sys_days ` is just a type alias for a `std::chrono::time_point`. So the ISO week date (`iso_week:year_weeknum_weekday`) is immediately interoperable with the entire `` library, just like `date::year_month_day` is. +And recall that `sys_days` is just a type alias for a `std::chrono::time_point`. So the ISO week date (`iso_week:year_weeknum_weekday`) is immediately interoperable with the entire `` library, just like `date::year_month_day` is. auto now = std::chrono::system_clock::now(); auto dp = date::floor(now); @@ -275,7 +275,7 @@ Which just output for me: 2016-W11-Sat 03:07:02.460737 -And because `iso_week:year_weeknum_weekday` is implicitly convertible to and from `sys_days `, that makes it immediately (and explicitly) convertible to any other calendar system that is implicitly convertible to and from `sys_days `: +And because `iso_week:year_weeknum_weekday` is implicitly convertible to and from `sys_days`, that makes it immediately (and explicitly) convertible to any other calendar system that is implicitly convertible to and from `sys_days`: auto civil_date = date::year_month_day{iso_date}; std::cout << civil_date << ' ' << time << '\n'; @@ -284,7 +284,7 @@ which outputs: 2016-03-19 03:07:02.460737 -And there you have it: `sys_days ` is a _Rosetta Stone_ for translating _any_ calendar to any other calendar. Just make your calendar convert to and from `sys_days `, and you have interoperability with _every_ other calendar which does so. +And there you have it: `sys_days` is a _Rosetta Stone_ for translating _any_ calendar to any other calendar. Just make your calendar convert to and from `sys_days`, and you have interoperability with _every_ other calendar which does so. using namespace date::literals; auto today = 2016_y/mar/19; @@ -381,7 +381,7 @@ Let's say you want to search the globe, and all time, for time zones when the da auto end = sys_days{jan/1/2035} + 0s; do { - auto info = z.get_info(begin, tz::utc); + auto info = z.get_info(begin); if (info.save != 0h && info.save != 1h) { std::cout << z.name() << " has a daylight savings offset of " @@ -396,9 +396,9 @@ Let's say you want to search the globe, and all time, for time zones when the da You first get a reference to the tz database, then iterate over each zone in the database. For each zone, set a range of time points to search over. In this example I start searching as far back as possible, and search forward to the year 2035. -Starting at the beginning of time, get an `Info` for that UTC `time_point`. An `Info` looks like this: +Starting at the beginning of time, get an `sys_info` for that UTC `time_point`. An `sys_info` looks like this: - struct Info + struct sys_info { second_point begin; second_point end;