Skip to content

Commit

Permalink
reuse fmt_safe_duration_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldreik committed Jun 17, 2019
1 parent 0a16794 commit 4a4ddb6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,9 @@ struct chrono_formatter {
// this may overflow and/or the result may not fit in the
// target type.
#if FMT_SAFE_DURATION_CAST
int ec;
// might need checked conversion (rep!=Rep)
auto tmpval = std::chrono::duration<rep, Period>(val);
s = safe_duration_cast::safe_duration_cast<seconds>(tmpval, ec);
if (ec) {
FMT_THROW(format_error("value would cause UB or the wrong result"));
}
s = fmt_safe_duration_cast<seconds>(tmpval);
#else
s = std::chrono::duration_cast<seconds>(
std::chrono::duration<rep, Period>(val));
Expand Down

0 comments on commit 4a4ddb6

Please sign in to comment.