Reputation: 449
Having trouble with:
auto n = std::chrono::system_clock::now();
std::chrono::sys_days sd = n;
Why ? n is a time_point and sd is also time_point (actually time_point<system_clock, days>)??
Upvotes: 3
Views: 296
Reputation: 29985
Here's how you do it:
#include <chrono>
int main() {
using namespace std::chrono;
auto const n = system_clock::now();
sys_days sd = floor<days>(n);
}
Did I know this off the top of my head? No, of course not. It was in the examples of cppreference.com.
Upvotes: 9