format_duration

mautrix.util.format_duration.format_duration(seconds)

Format seconds as a simple duration in weeks/days/hours/minutes/seconds.

Parameters

seconds (int) – The number of seconds as an integer. Must be positive.

Returns

The formatted duration.

Return type

str

Examples

>>> from mautrix.util.format_duration import format_duration
>>> format_duration(1234)
'20 minutes and 34 seconds'
>>> format_duration(987654)
'1 week, 4 days, 10 hours, 20 minutes and 54 seconds'
>>> format_duration(60)
'1 minute'
Raises

ValueError – if the duration is not positive.

Parameters

seconds (int) –

Return type

str