BeforeRelativeDate
Checks the given datetime has occured before the provided relative time.
python · Filters And Transformers
Source
import dateparser import demistomock as demisto from CommonServerPython import * from CommonServerUserPython import * def check_date(value: str, relative_date: str) -> bool: settings = {"TO_TIMEZONE": "UTC", "RETURN_AS_TIMEZONE_AWARE": False} v = dateparser.parse(value, settings=settings) # type: ignore[arg-type] da = dateparser.parse(relative_date, settings=settings) # type: ignore[arg-type] return v < da # type: ignore def main(): try: args = demisto.args() value = args.get("left", "") relative_date = args.get("right", "") if value == "" or relative_date == "": raise ValueError("A required input is missing or malformed.") result = check_date(value, relative_date) human_readable = f'# BeforeRelativeDate\nThe date *{value}* {"*IS*" if result else "*IS NOT*"} before *{relative_date}*' return_results(CommandResults(outputs_prefix="BeforeRelativeDate", readable_output=human_readable, outputs=result)) except Exception as e: return_error(message="Error Occured", error=str(e)) if __name__ in ("__builtin__", "builtins", "__main__"): main()
README
Checks the given datetime has occurred before the provided relative time.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | date, filter, Condition |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| left | Date value to check - Can be any time format. ex. “2020-01-01T00:00:00” |
| right | Relative time ex. “6 months ago” |
Outputs
The script returns a boolean value (true or false) indicating if the date is before the relative time.