[humanize] pad out duration to align fields

Fixes #933
pull/1170/head v0.11.2-rc2
Tim Stack 12 months ago
parent 4cb695fa68
commit 0083eaf675

@ -192,6 +192,9 @@ duration::to_string() const
amount,
curr_interval->symbol);
retval.insert(0, segment);
if (remaining > 0 && amount < 10 && curr_interval->symbol[0]) {
retval.insert(0, "0");
}
}
if (neg) {

@ -106,7 +106,10 @@ TEST_CASE("duration to_string")
std::string val;
val = humanize::time::duration::from_tv({25 * 60 * 60, 123000}).to_string();
CHECK(val == "1d1h0m0s");
CHECK(val == "1d01h00m00s");
val = humanize::time::duration::from_tv({25 * 60 * 60 + 25 * 60, 123000})
.to_string();
CHECK(val == "1d01h25m00s");
val = humanize::time::duration::from_tv({10, 123000}).to_string();
CHECK(val == "10s123");
val = humanize::time::duration::from_tv({10, 0}).to_string();

@ -1528,7 +1528,7 @@ humanize_duration(*secs*)
.. code-block:: custsqlite
;SELECT humanize_duration(15 * 60)
15m0s
15m00s
To format a sub-second value:

Loading…
Cancel
Save