Skip to main content

build_lifetime_snippet

Function build_lifetime_snippet 

Source
pub fn build_lifetime_snippet() -> String
Expand description

Shell fragment computing how long the container was alive.

Best effort by design: date -d is GNU, date -j -f is BSD, and a host that offers neither leaves the lifetime unknown rather than guessing.

BSD date cannot parse the fractional seconds docker reports, so the fallback strips them before parsing and adds them back afterwards. Truncating both timestamps to whole seconds instead would not cancel out: a container alive from .942 to .740 of the next-but-five second measures 5.798s but truncates to 6.000s, and the error can reach a full second either way.