mirror of
https://github.com/HowardHinnant/date.git
synced 2025-01-14 01:37:57 +08:00
Round when parsing seconds instead of duration_cast.
This commit is contained in:
parent
383214dea6
commit
d57d764707
@ -8046,12 +8046,13 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
{
|
||||
using Duration = std::chrono::duration<Rep, Period>;
|
||||
using CT = typename std::common_type<Duration, std::chrono::seconds>::type;
|
||||
using detail::round_i;
|
||||
fields<CT> fds{};
|
||||
date::from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.has_tod)
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
d = std::chrono::duration_cast<Duration>(fds.tod.to_duration());
|
||||
d = round_i<Duration>(fds.tod.to_duration());
|
||||
return is;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user