From 45899df1c91c254e2403068cfbce8df68807f25a Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 3 May 2023 18:09:41 -0400 Subject: [PATCH] A few more time macros --- custom_templates/time.jinja | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/custom_templates/time.jinja b/custom_templates/time.jinja index d603fd9..dda51c7 100644 --- a/custom_templates/time.jinja +++ b/custom_templates/time.jinja @@ -3,7 +3,15 @@ {% endmacro %} {% macro current_time_12hr() %} -{{ now().strftime("%-I:%M %p") }} +{{ now().strftime('%-I:%M %p') }} +{% endmacro %} + +{% macro current_time_24hr() %} +{{ now().strftime('%H:%M') }} +{% endmacro %} + +{% macro current_date_input() %} +{{ now().strftime('%Y-%m-%d') }} {% endmacro %} {% macro input_datetime_12hr(entity) %} @@ -30,6 +38,10 @@ {{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }} {% endmacro %} +{% macro increment_datetime_from_now(hours) %} +{{ (as_timestamp(now()) + ((hours* 60) * 60)) | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }} +{% endmacro %} + {% macro ct() %} {{ ((now().hour * 60 + now().minute) * 60 ) }} {% endmacro %} \ No newline at end of file