Updated Examples and Recipes (markdown)

Howard Hinnant
2021-04-16 21:08:04 -04:00
parent 3ab7a72785
commit 643336343b

@@ -675,8 +675,8 @@ The first recipe below is based on an example from [Howard Hinnant](https://gith
using namespace date;
auto time = std::chrono::system_clock::now();
auto daypoint = floor<days>(time);
auto ymd = year_month_day(daypoint); // calendar date
auto tod = make_time(time - daypoint); // Yields time_of_day type
year_month_day ymd = daypoint; // calendar date
hh_mm_ss tod{time - daypoint}; // Yields time_of_day type
// Obtain individual components as integers
auto y = int(ymd.year());
@@ -697,7 +697,7 @@ std::tm to_calendar_time(std::chrono::time_point<Clock, Duration> tp)
auto date = floor<days>(tp);
auto ymd = year_month_day(date);
auto weekday = year_month_weekday(date).weekday_indexed().weekday();
auto tod = make_time(tp - date);
hh_mm_ss tod{tp - date};
days daysSinceJan1 = date - sys_days(ymd.year()/1/1);
std::tm result{};
@@ -1032,7 +1032,7 @@ And recall that `sys_days` is just a type alias for a `std::chrono::time_point<s
auto now = std::chrono::system_clock::now();
auto dp = date::floor<iso_week::days>(now);
iso_week::year_weeknum_weekday iso_date = dp;
auto time = date::make_time(now-dp);
date::hh_mm_ss time{now-dp};
std::cout << iso_date << ' ' << time << '\n';
```