Skip to content

Commit

Permalink
Rename locale-specific tm formatting function
Browse files Browse the repository at this point in the history
  • Loading branch information
phprus committed Nov 5, 2021
1 parent 7c08236 commit 98ac2e2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ inline null<> gmtime_r(...) { return null<>(); }
inline null<> gmtime_s(...) { return null<>(); }

template <typename Char>
inline auto do_write(const std::tm& time, const std::locale& loc, char format,
char modifier) -> std::basic_string<Char> {
inline auto do_write_localized(const std::tm& time, const std::locale& loc,
char format, char modifier)
-> std::basic_string<Char> {
auto&& os = std::basic_ostringstream<Char>();
os.imbue(loc);
using iterator = std::ostreambuf_iterator<Char>;
Expand All @@ -303,17 +304,17 @@ inline auto do_write(const std::tm& time, const std::locale& loc, char format,

template <typename Char, typename OutputIt,
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
auto write(OutputIt out, const std::tm& time, const std::locale& loc,
char format, char modifier = 0) -> OutputIt {
auto str = do_write<Char>(time, loc, format, modifier);
auto write_localized(OutputIt out, const std::tm& time, const std::locale& loc,
char format, char modifier = 0) -> OutputIt {
auto str = do_write_localized<Char>(time, loc, format, modifier);
return std::copy(str.begin(), str.end(), out);
}

template <typename Char, typename OutputIt,
FMT_ENABLE_IF(std::is_same<Char, char>::value)>
auto write(OutputIt out, const std::tm& time, const std::locale& loc,
char format, char modifier = 0) -> OutputIt {
auto str = do_write<char>(time, loc, format, modifier);
auto write_localized(OutputIt out, const std::tm& time, const std::locale& loc,
char format, char modifier = 0) -> OutputIt {
auto str = do_write_localized<char>(time, loc, format, modifier);
if (detail::is_utf8() && loc != std::locale::classic()) {
// char16_t and char32_t codecvts are broken in MSVC (linkage errors) and
// gcc-4.
Expand Down Expand Up @@ -984,7 +985,7 @@ template <typename OutputIt, typename Char> class tm_writer {
}

void format_localized(char format, char modifier = 0) {
out_ = write<Char>(out_, tm_, loc_, format, modifier);
out_ = write_localized<Char>(out_, tm_, loc_, format, modifier);
}

public:
Expand Down

0 comments on commit 98ac2e2

Please sign in to comment.