human_readable_time#
- detkit.human_readable_time(t, pad=False)#
Converts time (in seconds) as float to string with time unit.
- Parameters:
- tfloat
Time in seconds
- padboolean, default=False
Is True, the output string is padded from left so that it always have fixed and consistent length. This is useful to print in columns.
- Returns:
- stringstr
A string containing time and the unit of time as follows:
'ps': pico-second (\(10^{-12}\) second)'ns': nano-second (\(10^{-9}\) second)'us': micro-second (\(10^{-6}\) second)'ms': milli-second (\(10^{-3}\) second)'se': second'mn': minute'hr': hour'dy': day'mo': month
See also
Examples
>>> from detkit import human_readable_time >>> print(human_readable_time(0.01)) 10 ms >>> print(human_readable_time(0.01, pad=True)) 10 ms