mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-06 06:04:27 +02:00
Updated Examples and Recipes (markdown)
@@ -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);
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user