Skip to main content

format_compact_session_elapsed

Function format_compact_session_elapsed 

Source
pub fn format_compact_session_elapsed(secs: f64) -> String
Expand description

Compact 8-char session-elapsed clock with a unit suffix (s/m/h) that scales as the run gets longer. The fractional precision shrinks step-by-step so the integer part stays bounded and the total width is constant — log rows column-align cleanly even when the suffix changes underneath them.

Layout (always 8 visible chars):

MagnitudeExampleShape
0 – 9.99999s1.23456s1 int + 5 frac + s
10 – 99.9999s99.1234s2 int + 4 frac + s
100 – 999.999s999.123s3 int + 3 frac + s
16m – 1h1.23456m1 int + 5 frac + m
10m – 100m99.1234m2 int + 4 frac + m
100m – 1000m999.123m3 int + 3 frac + m
1h+1.23456hhours scaled
10h+99.1234h
100h+999.123h

Beyond 999.999h (≈ 41 days) the column widens, matching the format_elapsed_seconds precedent for runs longer than fit in 7 chars: the integer part grows, the fractional precision stays at 3.