Skip to content

Commit

Permalink
Round when parsing seconds instead of duration_cast.
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardHinnant committed Jul 26, 2021
1 parent 383214d commit d57d764
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/date/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d57d764

Please sign in to comment.