mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 20:18:49 +00:00
Implement locale-specific minute formatting
This commit is contained in:
parent
639de21757
commit
aa3b5aba41
@ -206,9 +206,13 @@ struct chrono_formatter {
|
|||||||
format_localized(time, 'I');
|
format_localized(time, 'I');
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_minute(numeric_system) {
|
void on_minute(numeric_system ns) {
|
||||||
auto minute = to_int((s.count() / 60) % 60);
|
auto minute = to_int((s.count() / 60) % 60);
|
||||||
write(minute, 2);
|
if (ns == numeric_system::standard)
|
||||||
|
return write(minute, 2);
|
||||||
|
auto time = tm();
|
||||||
|
time.tm_minute = minute;
|
||||||
|
format_localized(time, 'M');
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_second(numeric_system) {
|
void on_second(numeric_system) {
|
||||||
|
@ -107,5 +107,8 @@ TEST(TimeTest, ChronoLocale) {
|
|||||||
EXPECT_EQ(str(), fmt::format(loc, "{:%OH}", std::chrono::hours(14)));
|
EXPECT_EQ(str(), fmt::format(loc, "{:%OH}", std::chrono::hours(14)));
|
||||||
os << std::put_time(&time, "%OI");
|
os << std::put_time(&time, "%OI");
|
||||||
EXPECT_EQ(str(), fmt::format(loc, "{:%OI}", std::chrono::hours(14)));
|
EXPECT_EQ(str(), fmt::format(loc, "{:%OI}", std::chrono::hours(14)));
|
||||||
|
time.tm_minute = 42;
|
||||||
|
os << std::put_time(&time, "%OM");
|
||||||
|
EXPECT_EQ(str(), fmt::format(loc, "{:%OM}", std::chrono::minutes(42)));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user