We still need to deal with structures like time_tor tm.
chronoReally conveniently designed to calculate time intervals. But time_point... Is it difficult to implement direct access to the year, month, day, etc. And formatted fingerprint? For example:
void print_date(std::chrono::time_point<std::chrono::system_clock> tp){
time_t raw_time = system_clock::to_time_t(tp);
tm* time_info = localtime(&raw_time);
char date[20] = {};
strftime(date, 20, "%Y-%m-%d %H:%M", time_info);
cout << date;
}
I think many programmers write something like this. There was probably a good reason for this design. But what could be this reason?
source
share