From 7816c3b48f343acba22608dd2046e4ceec5de6e7 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sun, 28 Aug 2016 14:26:22 -0400 Subject: [PATCH] Eliminate dependence on OS's timegm / _mkgmtime Apple's OS timegm has a 32 bit bug meaning it can't parse dates earlier than 1901-12-13 20:45:52. --- date.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/date.h b/date.h index 8017db0..cf28bd5 100644 --- a/date.h +++ b/date.h @@ -4286,12 +4286,12 @@ parse(std::basic_istream& is, f.get(is, 0, is, err, &tm, b, e); if ((err & ios_base::failbit) == 0) { -#ifdef _WIN32 - auto tt = _mkgmtime(&tm); -#else - auto tt = timegm(&tm); -#endif - tp = floor(system_clock::from_time_t(tt) + subseconds); + using namespace std::chrono; + tp = floor(sys_days{year{tm.tm_year + 1900}/ + (tm.tm_mon+1)/ + (tm.tm_mday)} + + hours{tm.tm_hour} + minutes{tm.tm_min} + + seconds{tm.tm_sec} + subseconds); abbrev = std::move(temp_abbrev); offset = temp_offset; }