Duration
time_duration¶
Convert a count of seconds into a human-readable duration string. e.g. "1d 4h 3m 22s". Seconds always shown; higher units shown only when non-zero. With --compact, spaces between units are omitted: "1d4h3m22s".
Example¶
time_duration 90 # => "1m 30s"
time_duration 3661 # => "1h 1m 1s"
time_duration 90061 # => "1d 1h 1m 1s"
time_duration --compact 3661 # => "1h1m1s"
Arguments¶
- $1 (int): Seconds (non-negative integer)
Exit codes¶
- 0: Always
Output on stdout¶
- Human-readable duration string
time_diff_seconds¶
Compute elapsed seconds between two epoch timestamps, or between a given epoch and now if only one argument is provided. Result is always non-negative (absolute difference).
Example¶
time_diff_seconds 1700000000 1700003661 # => 3661
time_diff_seconds 1700000000 # => (seconds since that epoch)
Arguments¶
- $1 (int): Start epoch (seconds since Unix epoch)
- $2 (int): End epoch (default: current time)
Exit codes¶
- 0: Always
Output on stdout¶
- Elapsed seconds