Time¶
netutils.time
¶
Functions for working with time.
uptime_seconds_to_string(uptime_seconds)
¶
Converts uptime in seconds to uptime in string format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uptime_seconds |
int
|
Uptime in seconds. |
required |
Returns:
Type | Description |
---|---|
str
|
Uptime in string format. |
Examples:
>>> from netutils.time import uptime_seconds_to_string
>>> uptime_seconds_to_string(7250)
'2 hours, 50 seconds'
Source code in netutils/time.py
uptime_string_to_seconds(uptime_string)
¶
Converts uptime string seconds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uptime_string |
str
|
Uptime in string format |
required |
Returns:
Type | Description |
---|---|
int
|
Uptime string converted to seconds. |
Examples:
>>> from netutils.time import uptime_string_to_seconds
>>> uptime_string_to_seconds("58 minutes")
3480
>>> from netutils.time import uptime_string_to_seconds
>>> uptime_string_to_seconds("4m15s")
255
Raises:
Type | Description |
---|---|
ValueError
|
When uptime_string is unable to be parsed by regex. |