parse-timeDate and Timepretty-run-time-durationpretty-durationGoTo Top

pretty-duration   seconds &optional maximum-fields destination => result[Function]

Purpose
Format a numeric time duration (in seconds) into descriptive text.

Package   :gbbopen-tools

Module   :gbbopen-tools

Arguments and values

seconds     A number
maximum-fields     An integer from 1–5 indicating maximum number of fields to include in the descriptive string (default is 5, indicating all fields should be included)
destination     Either nil, t, a stream, or a string with a fill pointer (default is nil)
result     A string or nil

Returns
If destination is non-nil, then nil; otherwise, a string.

Description
The value of seconds is rounded to the nearest 100th of a second before conversion. Fields omitted by maximum-fields cause appropriate rounding of the generated description.

See also
    brief-duration
    brief-run-time-duration
    parse-duration
    pretty-run-time-duration

Examples

  > (pretty-duration 1000)
  "16 minutes, 40 seconds"
  > (pretty-duration -1000)
  "minus 16 minutes, 40 seconds"
  > (pretty-duration -1000.12345)
  "minus 16 minutes, 40.12 seconds"
  > (pretty-duration -1000.12543)
  "minus 16 minutes, 40.13 seconds"
  > (pretty-duration 166611.9)
  "1 day, 22 hours, 16 minutes, 51.91 seconds"
  > (pretty-duration 166611.9 4)
  "1 day, 22 hours, 16 minutes, 52 seconds"
  > (pretty-duration 166611.9 3)
  "1 day, 22 hours, 17 minutes"
  > (pretty-duration 166611.9 2)
  "1 day, 22 hours"
  > (pretty-duration 166611.9 1)
  "2 days"
  > (pretty-duration 31556952)
  "365 days, 5 hours, 49 minutes, 12 seconds"
  >


The GBBopen Project


parse-timeDate and Timepretty-run-time-durationpretty-durationGoTo Top