Skip to main content

humanize_seconds

Show seconds in human form.

For example, 60 becomes "1 minute", and 7200 becomes "2 hours".
def humanize_seconds(
secs: int,
prefix: str = '',
sep: str = '',
now: str = 'now',
microseconds: bool = false
) - > str

Show seconds in human form. For example, 60 becomes "1 minute", and 7200 becomes "2 hours".

Parameters

NameTypeDescription
secsintThe total number of seconds to be converted into a human-readable time duration.
prefixstr = ''A preposition or string to prepend to the output, such as 'in' to produce 'in 1 second'.
sepstr = ''A separator string inserted between the prefix and the time duration text.
nowstr = 'now'The literal string to return when the duration is zero seconds.
microsecondsbool = falseWhether to include microsecond precision in the output for durations less than one second.

Returns

TypeDescription
strA human-readable string representing the duration, such as "2 hours" or the value of the 'now' parameter if the duration is zero.