Reputation: 1479
C++11 provide a function to return current time. However, I cannot find there is a function to return current day. And I use boost to do so.
boost::gregorian::date TODAY = boost::gregorian::day_clock::local_day();
Is there any way to achieve the same result using chrono?
EDIT: What I want is to use time_point to represent current day. That means the hour,minute and second are zero 2013-07-31 00:00:00
Upvotes: 4
Views: 771
Reputation: 473447
Chronos doesn't extend to date issues; that's really not it's purpose. The dividing line between date issues and "time" issues is the day. And Chrono doesn't define a day type.
But you could just divide the time in hours by 24. Or even better, define your own duration typedef and use that:
typedef std::duration<std::uint32_t, std::ratio<3600 * 24>> day;
Then just use a time_point
with that type:
std::chrono::time_point<std::chrono::system_clock, day> day_getter;
day_getter.time_since_epoch();
Upvotes: 6