hbutils.scale.time

Overview:

Useful utilities for time units, such as h/m/s.

time_to_duration

hbutils.scale.time.time_to_duration(time_: Union[float, int, str]) → Union[float, int][source]
Overview:

Turn any types of time duration in time value in seconds.

Arguments:
  • time_ (Union[int, float, str]): Any types of time duration.

Returns:
  • bytes (int): Time duration value in seconds.

Examples::
>>> from hbutils.scale import time_to_duration
>>> time_to_duration(23344)
23344
>>> time_to_duration(233.54)
233.54
>>> time_to_duration('1h343m67.4s')
24247.4
>>> time_to_duration('0:03:53.540000')
233.54

time_to_delta_str

hbutils.scale.time.time_to_delta_str(time_: Union[float, int, str]) → str[source]
Overview:

Turn any types of time duration in time value in formatted string.

Arguments:
  • time_ (Union[int, float, str]): Any types of time duration.

Returns:
  • bytes (int): Time duration value in formatted string.

Examples::
>>> from hbutils.scale import time_to_delta_str
>>> time_to_delta_str(23344)
'6:29:04'
>>> time_to_delta_str(233.54)
'0:03:53.540000'
>>> time_to_delta_str('1h343m67.4s')
'6:44:07.400000'