forked from HowardHinnant/date
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.
This commit is contained in:
12
date.h
12
date.h
@@ -4286,12 +4286,12 @@ parse(std::basic_istream<CharT, Traits>& is,
|
|||||||
f.get(is, 0, is, err, &tm, b, e);
|
f.get(is, 0, is, err, &tm, b, e);
|
||||||
if ((err & ios_base::failbit) == 0)
|
if ((err & ios_base::failbit) == 0)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
using namespace std::chrono;
|
||||||
auto tt = _mkgmtime(&tm);
|
tp = floor<Duration>(sys_days{year{tm.tm_year + 1900}/
|
||||||
#else
|
(tm.tm_mon+1)/
|
||||||
auto tt = timegm(&tm);
|
(tm.tm_mday)} +
|
||||||
#endif
|
hours{tm.tm_hour} + minutes{tm.tm_min} +
|
||||||
tp = floor<Duration>(system_clock::from_time_t(tt) + subseconds);
|
seconds{tm.tm_sec} + subseconds);
|
||||||
abbrev = std::move(temp_abbrev);
|
abbrev = std::move(temp_abbrev);
|
||||||
offset = temp_offset;
|
offset = temp_offset;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user