diff --git a/Examples-and-Recipes.md b/Examples-and-Recipes.md index 3916664..3f45cea 100644 --- a/Examples-and-Recipes.md +++ b/Examples-and-Recipes.md @@ -13,7 +13,10 @@ using namespace std::chrono; using namespace date; // Component values (as obtained from an UI form, for example) int y=2015, m=7, d=30, h=12, min=34, s=56; -system_clock::time_point = day_point(year(y)/m/d) + +auto ymd = year(y)/m/d; // Yields a year_month_day type +if (!ymd.ok()) + throw std::runtime_error("Invalid date"); +system_clock::time_point = day_point(ymd) + hours(h) + minutes(min) + seconds(s); ```