If I do the following:
auto time = std::chrono::system_clock::duration::zero();
std::cout << time.count() << std::endl;
time += std::chrono::years(2024 - 1970);
std::cout << time.count() << std::endl;
It comes out to be Monday, January 1, 2024 2:16:48 AM, not 12 AM. I want to represent historic calendar dates. year_month_day
and hh_mm_ss
are available for use, but I enjoy having the ability of getting time_point::time_since_epoch()
. I need this because it is a convenient way of storing date and time data in a database as a single int64. Is there a way to get the best of both worlds?
As I see it my only options are to handle the timings myself and keep using std::chrono
, but this defeats the purpose of using std::chrono
, or to use chrono::year_month_day
and chrono::hh_mm_ss
and deal with the database in a different way.