Add default parameter to as_datetime documentation (#31048)

This commit is contained in:
Martijn van der Pol 2024-01-29 18:51:50 +01:00 committed by GitHub
parent eae332c2d0
commit 8cfc596b17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -587,7 +587,7 @@ For example, if you wanted to select a field from `trigger` in an automation bas
{% endraw %}
- `as_datetime()` converts a string containing a timestamp, or valid UNIX timestamp, to a datetime object.
- `as_datetime(value, default)` converts a string containing a timestamp, or valid UNIX timestamp, to a datetime object. If that fails, returns the `default` value, or if omitted raises an error. This function can also be used as a filter.
- `as_timestamp(value, default)` converts datetime object or string to UNIX timestamp. If that fails, returns the `default` value, or if omitted raises an error. This function can also be used as a filter.
- `as_local()` converts datetime object to local time. This function can also be used as a filter.
- `strptime(string, format, default)` parses a string based on a [format](https://docs.python.org/3.10/library/datetime.html#strftime-and-strptime-behavior) and returns a datetime object. If that fails, it returns the `default` value or, if omitted, raises an error.