| ... | ... | @@ -888,6 +888,7 @@ pub fn printInt( |
| 888 | 888 | 'X' => return printIntOptions(bw, int_value, 16, .upper, options), |
| 889 | 889 | 'o' => return printIntOptions(bw, int_value, 8, .lower, options), |
| 890 | 890 | 'B' => return printByteSize(bw, int_value, .decimal, options), |
| 891 | 'D' => return printDuration(bw, int_value, options), |
| 891 | 892 | else => invalidFmtError(fmt, value), |
| 892 | 893 | }, |
| 893 | 894 | 2 => { |
| ... | ... | @@ -1248,7 +1249,9 @@ pub fn printDurationUnsigned(bw: *BufferedWriter, ns: u64) anyerror!void { |
| 1248 | 1249 | if (frac > 0) { |
| 1249 | 1250 | // Write up to 3 decimal places |
| 1250 | 1251 | var decimal_buf = [_]u8{ '.', 0, 0, 0 }; |
| 1251 | | assert(printInt(decimal_buf[1..], frac, 10, .lower, .{ .fill = '0', .width = 3 }) == 3); |
| 1252 | var inner: BufferedWriter = undefined; |
| 1253 | inner.initFixed(decimal_buf[1..]); |
| 1254 | inner.printIntOptions(frac, 10, .lower, .{ .fill = '0', .width = 3 }) catch unreachable; |
| 1252 | 1255 | var end: usize = 4; |
| 1253 | 1256 | while (end > 1) : (end -= 1) { |
| 1254 | 1257 | if (decimal_buf[end - 1] != '0') break; |
| ... | ... | @@ -1272,8 +1275,8 @@ pub fn printDuration(bw: *BufferedWriter, nanoseconds: anytype, options: std.fmt |
| 1272 | 1275 | var sub_bw: BufferedWriter = undefined; |
| 1273 | 1276 | sub_bw.initFixed(&buf); |
| 1274 | 1277 | switch (@typeInfo(@TypeOf(nanoseconds)).int.signedness) { |
| 1275 | | .signed => sub_bw.printDurationSigned(nanoseconds, options) catch unreachable, |
| 1276 | | .unsigned => sub_bw.printDurationUnsigned(nanoseconds, options) catch unreachable, |
| 1278 | .signed => sub_bw.printDurationSigned(nanoseconds) catch unreachable, |
| 1279 | .unsigned => sub_bw.printDurationUnsigned(nanoseconds) catch unreachable, |
| 1277 | 1280 | } |
| 1278 | 1281 | return alignBufferOptions(bw, sub_bw.getWritten(), options); |
| 1279 | 1282 | } |