#include namespace UtilityTools { TimePoint time_point2zero(TimePoint time_point) { return second_zero2time_point(time_point2second_zero(time_point)); } int time_point2second_zero(TimePoint time_point) { int seconds = (time_point.time_since_epoch().count()) / (size_t)pow(10, 9); return 86400 * (int)((seconds + 28800) / 86400) - 28800; } TimePoint second_zero2time_point(int seconds) { auto st_s = std::chrono::seconds(seconds); auto time_date = std::chrono::time_point( st_s); return time_date; } int diff_days(TimePoint stime, TimePoint etime) { return std::chrono::duration_cast(etime - stime).count(); } TimePoint string2TimePoint(std::string time_str, const std::string& fmt) { std::tm tm = {}; std::stringstream ss(time_str); ss >> std::get_time(&tm, fmt.c_str()); return std::chrono::system_clock::from_time_t(std::mktime(&tm)); } } // namespace UtilityTools