Add UNIX timestamp detection to the as_datetime template filter (#20394)

This commit is contained in:
Jan Bouwhuis 2021-11-24 09:52:13 +01:00 committed by GitHub
parent 09bb6e8379
commit 777a78bf6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -318,7 +318,7 @@ The same thing can also be expressed as a filter:
{% endraw %}
- `as_datetime()` converts a string containing a timestamp to a datetime object.
- `as_datetime()` converts a string containing a timestamp, or valid UNIX 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.
- `strptime(string, format)` parses a string based on a [format](https://docs.python.org/3.8/library/datetime.html#strftime-and-strptime-behavior) and returns a datetime object. If that fails, returns the `default` value, or if omitted the unprocessed input value.