TimeHelpers
psengine.helpers.helpers.TimeHelpers
¶
Helpers for time related functions.
is_rel_time_valid
staticmethod
¶
Helper function to determine if relative time expression is valid.
| PARAMETER | DESCRIPTION |
|---|---|
rel_time
|
Relative time expression to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if valid, False otherwise. |
Source code in psengine/helpers/helpers.py
is_valid_time_range
staticmethod
¶
Verifies if an ISO 8601 compliant time range was specified.
| PARAMETER | DESCRIPTION |
|---|---|
range_
|
ISO 8601-style time range to validate.
TYPE:
|
Example
For format reference see: https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if valid, False otherwise. |
Source code in psengine/helpers/helpers.py
rel_time_to_date
staticmethod
¶
Convert a relative time to a date.
relative_time specification:
- 1h means 1 hour ago
- -1h means 1 hour ago
- +1h means 1 hour in the future
| PARAMETER | DESCRIPTION |
|---|---|
relative_time
|
Relative time string like '7d', '3h', '4m' (minutes).
TYPE:
|
start_time
|
Defined starting time in format %Y-%m-%d %H:%M:%S, if none it will be the run time
TYPE:
|
Example
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
| RETURNS | DESCRIPTION |
|---|---|
str
|
Formatted date string in ISO format, e.g., '2022-08-08T13:11'. |