mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 01:06:52 +00:00
Add template as_timedelta (#22740)
This commit is contained in:
parent
5646666ce6
commit
479413cc5f
@ -424,6 +424,17 @@ For example, if you wanted to select a field from `trigger` in an automation bas
|
||||
|
||||
{% endraw %}
|
||||
|
||||
- `as_timedelta(string)` converts a string to a timedelta object. Expects data in the format `DD HH:MM:SS.uuuuuu`, `DD HH:MM:SS,uuuuuu`, or as specified by ISO 8601 (e.g. `P4DT1H15M20S` which is equivalent to `4 1:15:20`) or PostgreSQL’s day-time interval format (e.g. `3 days 04:05:06`) This function can also be used as a filter.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
# Renders to "00:10:00"
|
||||
{{ as_timedelta("PT10M") }}
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
- Filter `timestamp_local(default)` converts a UNIX timestamp to the ISO format string representation as date/time in your local timezone. If that fails, returns the `default` value, or if omitted the unprocessed input value. If a custom string format is needed in the string, use `timestamp_custom` instead.
|
||||
- Filter `timestamp_utc(default)` converts a UNIX timestamp to the ISO format string representation representation as date/time in UTC timezone. If that fails, returns the `default` value, or if omitted the unprocessed input value. If a custom string format is needed in the string, use `timestamp_custom` instead.
|
||||
- Filter `timestamp_custom(format_string, local=True, default)` converts an UNIX timestamp to its string representation based on a custom format, the use of a local timezone is default. If that fails, returns the `default` value, or if omitted the unprocessed input value. Supports the standard [Python time formatting options](https://docs.python.org/3/library/time.html#time.strftime).
|
||||
|
Loading…
x
Reference in New Issue
Block a user