Skip to content

Commit c553499

Browse files
committed
Minor cleanup
1 parent f5ec5ad commit c553499

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

include/fmt/chrono.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ template <typename Char> struct formatter<month, Char> {
21502150
template <typename FormatContext>
21512151
auto format(month m, FormatContext& ctx) const -> decltype(ctx.out()) {
21522152
auto time = std::tm();
2153-
// std::chrono::month has a range of 1-12, std::tm requires 0-11
2153+
// std::chrono::month has a range of 1-12, std::tm requires 0-11.
21542154
time.tm_mon = static_cast<int>(static_cast<unsigned>(m)) - 1;
21552155
detail::get_locale loc(localized, ctx.locale());
21562156
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
@@ -2168,7 +2168,7 @@ template <typename Char> struct formatter<year, Char> {
21682168
template <typename FormatContext>
21692169
auto format(year y, FormatContext& ctx) const -> decltype(ctx.out()) {
21702170
auto time = std::tm();
2171-
// std::tm::tm_year is years since 1900
2171+
// std::tm::tm_year is years since 1900.
21722172
time.tm_year = static_cast<int>(y) - 1900;
21732173
detail::get_locale loc(true, ctx.locale());
21742174
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);

test/chrono-test.cc

+4-9
Original file line numberDiff line numberDiff line change
@@ -1014,13 +1014,8 @@ TEST(chrono_test, out_of_range) {
10141014
}
10151015

10161016
TEST(chrono_test, year_month_day) {
1017-
auto loc = get_locale("es_ES.UTF-8");
1018-
std::locale::global(loc);
1019-
auto year = fmt::year(2024);
1020-
auto month = fmt::month(1);
1021-
auto day = fmt::day(1);
1022-
1023-
EXPECT_EQ(fmt::format("{}", year), "2024");
1024-
EXPECT_EQ(fmt::format("{}", month), "Jan");
1025-
EXPECT_EQ(fmt::format("{}", day), "01");
1017+
std::locale::global(get_locale("es_ES.UTF-8"));
1018+
EXPECT_EQ(fmt::format("{}", fmt::year(2024)), "2024");
1019+
EXPECT_EQ(fmt::format("{}", fmt::month(1)), "Jan");
1020+
EXPECT_EQ(fmt::format("{}", fmt::day(1)), "01");
10261021
}

0 commit comments

Comments
 (0)