From 7a99b47309ef98f22e2c6890916a592eca9b879e Mon Sep 17 00:00:00 2001 From: The00Dustin <91274634+The00Dustin@users.noreply.github.com> Date: Mon, 20 Mar 2023 14:56:27 -0400 Subject: [PATCH] Include optional default value in strptime (#26667) Co-authored-by: Franck Nijhof --- source/_docs/configuration/templating.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index d3622b4d365..669fff9d255 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -510,7 +510,7 @@ For example, if you wanted to select a field from `trigger` in an automation bas - `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 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)` 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 raises an error. +- `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. - `relative_time` converts datetime object to its human-friendly "age" string. The age can be in second, minute, hour, day, month or year (but only the biggest unit is considered, e.g., if it's 2 days and 3 hours, "2 days" will be returned). Note that it only works for dates _in the past_. - `timedelta` returns a timedelta object and accepts the same arguments as the Python `datetime.timedelta` function -- days, seconds, microseconds, milliseconds, minutes, hours, weeks.