Apply clang-format
This commit is contained in:
parent
85a4cefd86
commit
21a828cd1c
@ -1119,7 +1119,8 @@ void write_floating_seconds(memory_buffer& buf, Duration duration) {
|
||||
}
|
||||
|
||||
template <typename Duration>
|
||||
void write_floating_seconds(memory_buffer& buf, Duration duration, int precision) {
|
||||
void write_floating_seconds(memory_buffer& buf, Duration duration,
|
||||
int precision) {
|
||||
if (precision < 0) {
|
||||
write_floating_seconds(buf, duration);
|
||||
return;
|
||||
@ -1894,16 +1895,19 @@ struct chrono_formatter {
|
||||
if (ns == numeric_system::standard) {
|
||||
if (std::is_floating_point<rep>::value) {
|
||||
auto buf = memory_buffer();
|
||||
write_floating_seconds(buf, std::chrono::duration<rep, Period>(val), precision);
|
||||
write_floating_seconds(buf, std::chrono::duration<rep, Period>(val),
|
||||
precision);
|
||||
if (negative) *out++ = '-';
|
||||
if (buf.size() < 2 || buf[1] == '.') *out++ = '0';
|
||||
out = std::copy(buf.begin(), buf.end(), out);
|
||||
} else {
|
||||
write(second(), 2);
|
||||
if (precision >= 0) {
|
||||
write_fractional_seconds<char_type>(out, std::chrono::duration<rep, Period>(val), precision);
|
||||
write_fractional_seconds<char_type>(
|
||||
out, std::chrono::duration<rep, Period>(val), precision);
|
||||
} else {
|
||||
write_fractional_seconds<char_type>(out, std::chrono::duration<rep, Period>(val));
|
||||
write_fractional_seconds<char_type>(
|
||||
out, std::chrono::duration<rep, Period>(val));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@ -612,11 +612,16 @@ TEST(chrono_test, cpp20_duration_subsecond_support) {
|
||||
"-13.420148734");
|
||||
EXPECT_EQ(fmt::format("{:%S}", std::chrono::milliseconds{1234}), "01.234");
|
||||
// Check subsecond presision modifier.
|
||||
EXPECT_EQ(fmt::format("{:.6%S}", std::chrono::nanoseconds{1234}), "00.000001");
|
||||
EXPECT_EQ(fmt::format("{:.18%S}", std::chrono::nanoseconds{1234}), "00.000001234000000000");
|
||||
EXPECT_EQ(fmt::format("{:.{}%S}", std::chrono::nanoseconds{1234}, 6), "00.000001");
|
||||
EXPECT_EQ(fmt::format("{:.6%S}", std::chrono::milliseconds{1234}), "01.234000");
|
||||
EXPECT_EQ(fmt::format("{:.6%S}", std::chrono::milliseconds{-1234}), "-01.234000");
|
||||
EXPECT_EQ(fmt::format("{:.6%S}", std::chrono::nanoseconds{1234}),
|
||||
"00.000001");
|
||||
EXPECT_EQ(fmt::format("{:.18%S}", std::chrono::nanoseconds{1234}),
|
||||
"00.000001234000000000");
|
||||
EXPECT_EQ(fmt::format("{:.{}%S}", std::chrono::nanoseconds{1234}, 6),
|
||||
"00.000001");
|
||||
EXPECT_EQ(fmt::format("{:.6%S}", std::chrono::milliseconds{1234}),
|
||||
"01.234000");
|
||||
EXPECT_EQ(fmt::format("{:.6%S}", std::chrono::milliseconds{-1234}),
|
||||
"-01.234000");
|
||||
EXPECT_EQ(fmt::format("{:.3%S}", std::chrono::seconds{1234}), "34.000");
|
||||
EXPECT_EQ(fmt::format("{:.3%S}", std::chrono::hours{1234}), "00.000");
|
||||
EXPECT_EQ(fmt::format("{:.5%S}", dms(1.234)), "00.00123");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user