datetime
Utility functions for handling time/timezones.
random_delay(min_delay_sec, max_delay_sec)
¶
Sleep for a random number of seconds in [min_delay_sec, max_delay_sec].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_delay_sec
|
float
|
The minimum delay in seconds. |
required |
max_delay_sec
|
float
|
The maximum delay in seconds. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If min_delay_sec < 0 or max_delay_sec <= min_delay_sec. |
Returns:
| Type | Description |
|---|---|
None
|
None |
Examples:
utc_datetime_to_utc_int(dt)
¶
Given a UTC datetime object, return the seconds offset from midnight 01 January, 1970 UTC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
datetime
|
The UTC datetime object. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The seconds offset from midnight 01 January, 1970 UTC. |
Examples:
utc_time_now()
¶
utc_time_now_plus_delta(delta)
¶
Return the current time in UTC + a timedelta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delta
|
timedelta
|
The timedelta to add to the current time. |
required |
Returns:
| Type | Description |
|---|---|
datetime
|
The current time in UTC + the timedelta. |
Examples: