From fcdca67c5bc6ddbaac879b36b158abf678684894 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 27 Aug 2016 13:22:27 -0400 Subject: [PATCH] Switch to floor in format Need to round towards negative infinity for dates prior to the epoch, else the wrong answer gets formatted. --- date.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/date.h b/date.h index a638ebc..91935d2 100644 --- a/date.h +++ b/date.h @@ -4015,7 +4015,8 @@ format(const std::locale& loc, std::basic_string fmt, } auto& f = use_facet>(loc); basic_ostringstream os; - auto tt = system_clock::to_time_t(time_point_cast(sys_time{tp.time_since_epoch()})); + auto tt = system_clock::to_time_t( + floor(sys_time{tp.time_since_epoch()})); std::tm tm{}; #ifndef _MSC_VER gmtime_r(&tt, &tm);