Skip to content

Commit

Permalink
Don't use strftime (#2301)
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam authored Jul 10, 2024
1 parent 698fc4e commit 177e016
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
16 changes: 15 additions & 1 deletion responses/en/HassGetCurrentDate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ responses:
intents:
HassGetCurrentDate:
default: >
{% set months = {
1: 'January',
2: 'February',
3: 'March',
4: 'April',
5: 'May',
6: 'June',
7: 'July',
8: 'August',
9: 'September',
10: 'October',
11: 'November',
12: 'December',
} %}
{% set ordinal = {
1: '1st',
2: '2nd',
Expand Down Expand Up @@ -36,4 +50,4 @@ responses:
30: '30th',
31: '31st',
} %}
{{ slots.date.strftime('%B') }} {{ ordinal[slots.date.day] }}, {{ slots.date.year }}
{{ months[slots.date.month] }} {{ ordinal[slots.date.day] }}, {{ slots.date.year }}
9 changes: 5 additions & 4 deletions responses/en/HassGetCurrentTime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ responses:
intents:
HassGetCurrentTime:
default: >
{% set time_str = slots.time.strftime('%I:%M %p') %}
{% if time_str.startswith('0'): -%}
{{ time_str[1:] }}
{% set minute_str = '{0:02d}'.format(slots.time.minute) %}
{% if slots.time.hour <= 12: %}
{{ slots.time.hour }}:{{ minute_str }} AM
{% else: %}
{{ time_str }}
{{ slots.time.hour - 12 }}:{{ minute_str }} PM
{% endif %}

0 comments on commit 177e016

Please sign in to comment.