Description

Adds a specified amount of time to a given date.

Input

  • date (str or datetime): The date to which the time will be added. Can be a string or a datetime object.
  • date_format (str): The format of the date string if the date is provided as a string.
  • time_str (str): The time to add, specified as a string (e.g., ‘1w 2d 3h 30m’).

Output

A datetime object representing the new date with the added time.

Example

workflow:
  id: datadog-alerts
  description: handle alerts
  triggers:
    - type: alert
      filters:
        - key: source
          value: datadog
  actions:
    - name: set-reminder-date
      provider:
        type: console
        with:
          alert_message: keep.add_time_to_date("{{ alert.date }}", "%Y-%m-%dT%H:%M:%S.%f%z", "1w 2d 3h 30m")