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.
PARAMETER | DESCRIPTION |
---|---|
relative_time
|
Relative time string like '7d', '3h'. Minutes not supported.
TYPE:
|
Example
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the relative time is invalid. |
RETURNS | DESCRIPTION |
---|---|
str
|
Formatted date string in ISO format, e.g., '2022-08-08T13:11'. |