mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 00:21:13 +00:00
Remove duplicate implementation (#3144)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru> Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
parent
cd7202e039
commit
f67dbc9811
@ -2071,9 +2071,9 @@ struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
|
||||
const auto subsecs = std::chrono::duration_cast<Duration>(
|
||||
epoch - std::chrono::duration_cast<std::chrono::seconds>(epoch));
|
||||
|
||||
return formatter<std::tm, Char>::format(
|
||||
return formatter<std::tm, Char>::do_format(
|
||||
localtime(std::chrono::time_point_cast<std::chrono::seconds>(val)),
|
||||
ctx, subsecs);
|
||||
ctx, &subsecs);
|
||||
}
|
||||
|
||||
return formatter<std::tm, Char>::format(
|
||||
@ -2117,6 +2117,22 @@ template <typename Char> struct formatter<std::tm, Char> {
|
||||
return end;
|
||||
}
|
||||
|
||||
template <typename FormatContext, typename Duration>
|
||||
auto do_format(const std::tm& tm, FormatContext& ctx,
|
||||
const Duration* subsecs) const -> decltype(ctx.out()) {
|
||||
const auto loc_ref = ctx.locale();
|
||||
detail::get_locale loc(static_cast<bool>(loc_ref), loc_ref);
|
||||
auto w = detail::tm_writer<decltype(ctx.out()), Char, Duration>(
|
||||
loc, ctx.out(), tm, subsecs);
|
||||
if (spec_ == spec::year_month_day)
|
||||
w.on_iso_date();
|
||||
else if (spec_ == spec::hh_mm_ss)
|
||||
w.on_iso_time();
|
||||
else
|
||||
detail::parse_chrono_format(specs.begin(), specs.end(), w);
|
||||
return w.out();
|
||||
}
|
||||
|
||||
public:
|
||||
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
|
||||
-> decltype(ctx.begin()) {
|
||||
@ -2134,32 +2150,7 @@ template <typename Char> struct formatter<std::tm, Char> {
|
||||
template <typename FormatContext>
|
||||
auto format(const std::tm& tm, FormatContext& ctx) const
|
||||
-> decltype(ctx.out()) {
|
||||
const auto loc_ref = ctx.locale();
|
||||
detail::get_locale loc(static_cast<bool>(loc_ref), loc_ref);
|
||||
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), tm);
|
||||
if (spec_ == spec::year_month_day)
|
||||
w.on_iso_date();
|
||||
else if (spec_ == spec::hh_mm_ss)
|
||||
w.on_iso_time();
|
||||
else
|
||||
detail::parse_chrono_format(specs.begin(), specs.end(), w);
|
||||
return w.out();
|
||||
}
|
||||
|
||||
template <typename FormatContext, typename Duration>
|
||||
auto format(const std::tm& tm, FormatContext& ctx,
|
||||
const Duration& subsecs) const -> decltype(ctx.out()) {
|
||||
const auto loc_ref = ctx.locale();
|
||||
detail::get_locale loc(static_cast<bool>(loc_ref), loc_ref);
|
||||
auto w = detail::tm_writer<decltype(ctx.out()), Char, Duration>(
|
||||
loc, ctx.out(), tm, &subsecs);
|
||||
if (spec_ == spec::year_month_day)
|
||||
w.on_iso_date();
|
||||
else if (spec_ == spec::hh_mm_ss)
|
||||
w.on_iso_time();
|
||||
else
|
||||
detail::parse_chrono_format(specs.begin(), specs.end(), w);
|
||||
return w.out();
|
||||
return do_format<FormatContext, std::chrono::seconds>(tm, ctx, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user