Add template today_at function/filter docs. (#19804)

This commit is contained in:
Petro31 2021-10-22 13:51:54 -04:00 committed by GitHub
parent daee6a4852
commit ecf9abc851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,6 +278,17 @@ The same thing can also be expressed as a filter:
- `utcnow()` returns a datetime object of the current time in the UTC timezone.
- For specific values: `utcnow().second`, `utcnow().minute`, `utcnow().hour`, `utcnow().day`, `utcnow().month`, `utcnow().year`, `utcnow().weekday()` and `utcnow().isoweekday()`.
- Using `utcnow()` will cause templates to be refreshed at the start of every new minute.
- `today_at(value)` converts a string containing a military time format to a datetime object with today's date in your time zone.
{% raw %}
```yaml
# Is the current time past 10:15?
{{ now() > today_at("10:15") }}
```
{% endraw %}
- `as_datetime()` converts a string containing a timestamp to a datetime object.
- `as_timestamp(value, default)` converts datetime object or string to UNIX timestamp. If that fails, returns the `default` value, or if omitted `None`. This function also be used as a filter.
- `as_local()` converts datetime object to local time. This function also be used as a filter.