Skip to content

Commit

Permalink
Hopefully fixed template error on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
brcha committed May 18, 2021
1 parent 3bf4aba commit e41100c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,6 @@ inline size_t strftime(wchar_t* str, size_t count, const wchar_t* format,

FMT_END_DETAIL_NAMESPACE

template <class Rep, class Period, class = std::enable_if<
std::chrono::duration<Rep, Period>::min() < std::chrono::duration<Rep, Period>::zero()>>
constexpr std::chrono::duration<Rep, Period> abs(std::chrono::duration<Rep, Period> d)
{
return d >= d.zero() ? d : -d;
}

template <typename Char, typename Rep, typename Period>
struct formatter<std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<Rep, Period>>,
Char> : formatter<std::tm, Char> {
Expand All @@ -421,7 +414,10 @@ struct formatter<std::chrono::time_point<std::chrono::system_clock, std::chrono:
std::tm time = localtime(val);
auto epoch = val.time_since_epoch();
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(epoch);
auto subseconds = abs(std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(epoch - seconds));
// auto subseconds = abs(std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(epoch - seconds));
auto subseconds = std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(epoch - seconds);

if (subseconds < subseconds.zero()) subseconds = -subseconds;

This comment has been minimized.

Copy link
@ecorm

ecorm May 18, 2021

See my comments in your previous commit about using the equivalent of std::chrono::floor<std::chrono::seconds> both here and in localtime.


if (subseconds.count() > 0) {
auto width = std::to_string(Period::den).size() - 1;
Expand Down

0 comments on commit e41100c

Please sign in to comment.