Repository: fmtlib/fmt
File: include/fmt/chrono.h (C/C++)

Code before:
                              Duration::period::den>::value;
  // For non-integer values, we ensure at least 6 digits to get microsecond
  // precision.
  auto val = duration.count();
  if (num_fractional_digits < 6 &&
      static_cast<typename Duration::rep>(std::round(val)) != val)
    num_fractional_digits = 6;

  format_to(
      std::back_inserter(buf), runtime("{:.{}f}"),
      std::fmod(val *
                    static_cast<typename Duration::rep>(Duration::period::num) /
                    static_cast<typename Duration::rep>(Duration::period::den),
                static_cast<typename Duration::rep>(60)),
      num_fractional_digits);
}

template <typename Duration>
void write_floating_seconds(memory_buffer& buf, Duration duration,
                            int precision) {
  if (precision < 0) {
    write_floating_seconds(buf, duration);
    return;
  }

  FMT_ASSERT(std::is_floating_point<typename Duration::rep>::value, "");
  auto val = duration.count();

  format_to(
      std::back_inserter(buf), runtime("{:.{}f}"),
      std::fmod(val *
                    static_cast<typename Duration::rep>(Duration::period::num) /
                    static_cast<typename Duration::rep>(Duration::period::den),
                static_cast<typename Duration::rep>(60)),
      precision);
}

template <typename OutputIt, typename Char,
          typename Duration = std::chrono::seconds>
class tm_writer {
 private:
  static constexpr int days_per_week = 7;

  const std::locale& loc_;
  const bool is_classic_;
  OutputIt out_;
  const Duration* subsecs_;
  const std::tm& tm_;

  auto tm_sec() const noexcept -> int {
    FMT_ASSERT(tm_.tm_sec >= 0 && tm_.tm_sec <= 61, "");

Review comment (suggestion):
Let's add an alias for `typename Duration::rep` and use it here and in several places below. 

Code after:

  const std::locale& loc_;
  const bool is_classic_;
  OutputIt out_;
  const Duration* subsecs_;
  const std::tm& tm_;

  auto tm_sec() const noexcept -> int {
    FMT_ASSERT(tm_.tm_sec >= 0 && tm_.tm_sec <= 61, "");
    return tm_.tm_sec;
  }
  auto tm_min() const noexcept -> int {
    FMT_ASSERT(tm_.tm_min >= 0 && tm_.tm_min <= 59, "");
    return tm_.tm_min;
  }
  auto tm_hour() const noexcept -> int {
    FMT_ASSERT(tm_.tm_hour >= 0 && tm_.tm_hour <= 23, "");
    return tm_.tm_hour;
  }
  auto tm_mday() const noexcept -> int {
    FMT_ASSERT(tm_.tm_mday >= 1 && tm_.tm_mday <= 31, "");
    return tm_.tm_mday;
  }
  auto tm_mon() const noexcept -> int {
    FMT_ASSERT(tm_.tm_mon >= 0 && tm_.tm_mon <= 11, "");
    return tm_.tm_mon;
  }
  auto tm_year() const noexcept -> long long { return 1900ll + tm_.tm_year; }
  auto tm_wday() const noexcept -> int {
    FMT_ASSERT(tm_.tm_wday >= 0 && tm_.tm_wday <= 6, "");
    return tm_.tm_wday;
  }
  auto tm_yday() const noexcept -> int {
    FMT_ASSERT(tm_.tm_yday >= 0 && tm_.tm_yday <= 365, "");
    return tm_.tm_yday;
  }

  auto tm_hour12() const noexcept -> int {
    const auto h = tm_hour();
    const auto z = h < 12 ? h : h - 12;
    return z == 0 ? 12 : z;
  }

  // POSIX and the C Standard are unclear or inconsistent about what %C and %y
  // do if the year is negative or exceeds 9999. Use the convention that %C
  // concatenated with %y yields the same output as %Y, and that %Y contains at
  // least 4 characters, with more only if necessary.
  auto split_year_lower(long long year) const noexcept -> int {
    auto l = year % 100;
    if (l < 0) l = -l;  // l in [0, 99]
    return static_cast<int>(l);