-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HassGetDate and HassGetTime (#2300)
- Loading branch information
1 parent
3b877c2
commit 698fc4e
Showing
11 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
language: en | ||
responses: | ||
intents: | ||
HassGetCurrentDate: | ||
default: > | ||
{% set ordinal = { | ||
1: '1st', | ||
2: '2nd', | ||
3: '3rd', | ||
4: '4th', | ||
5: '5th', | ||
6: '6th', | ||
7: '7th', | ||
8: '8th', | ||
9: '9th', | ||
10: '10th', | ||
11: '11th', | ||
12: '12th', | ||
13: '13th', | ||
14: '14th', | ||
15: '15th', | ||
16: '16th', | ||
17: '17th', | ||
18: '18th', | ||
19: '19th', | ||
20: '20th', | ||
21: '21st', | ||
22: '22nd', | ||
23: '23rd', | ||
24: '24th', | ||
25: '25th', | ||
26: '26th', | ||
27: '27th', | ||
28: '28th', | ||
29: '29th', | ||
30: '30th', | ||
31: '31st', | ||
} %} | ||
{{ slots.date.strftime('%B') }} {{ ordinal[slots.date.day] }}, {{ slots.date.year }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: en | ||
responses: | ||
intents: | ||
HassGetCurrentTime: | ||
default: > | ||
{% set time_str = slots.time.strftime('%I:%M %p') %} | ||
{% if time_str.startswith('0'): -%} | ||
{{ time_str[1:] }} | ||
{% else: %} | ||
{{ time_str }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Generate a map for day numbers to ordinal words.""" | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import json | ||
from typing import Dict | ||
|
||
from unicode_rbnf import RbnfEngine, RulesetName | ||
|
||
from .const import LANGUAGES | ||
from .util import get_base_arg_parser | ||
|
||
|
||
def get_arguments() -> argparse.Namespace: | ||
"""Get parsed passed in arguments.""" | ||
parser = get_base_arg_parser() | ||
parser.add_argument( | ||
"--language", | ||
required=True, | ||
type=str, | ||
choices=LANGUAGES, | ||
help="The language to validate.", | ||
) | ||
return parser.parse_args() | ||
|
||
|
||
def run() -> int: | ||
args = get_arguments() | ||
|
||
engine = RbnfEngine.for_language(args.language) | ||
ordinals: Dict[int, str] = {} | ||
for day in range(1, 32): | ||
ordinals[day] = engine.format_number(day, ruleset_name=RulesetName.ORDINAL) | ||
|
||
print(json.dumps(ordinals, ensure_ascii=False, indent=2)) | ||
|
||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: en | ||
intents: | ||
HassGetCurrentDate: | ||
data: | ||
- sentences: | ||
- "(<what_is>|tell me) (todays|today's|the current) date" | ||
- "(<what_is>|tell me) the date[ today]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: en | ||
intents: | ||
HassGetCurrentTime: | ||
data: | ||
- sentences: | ||
- "(<what_is>|tell me) the [current] time" | ||
- "what time is it[ [right ]now]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: en | ||
tests: | ||
- sentences: | ||
- "what's the date" | ||
- "what's the date today" | ||
- "what is today's date" | ||
- "tell me the date" | ||
intent: | ||
name: HassGetCurrentDate | ||
response: September 17th, 2013 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: en | ||
tests: | ||
- sentences: | ||
- "what's the time" | ||
- "what time is it" | ||
- "what time is it right now" | ||
- "tell me the time" | ||
intent: | ||
name: HassGetCurrentTime | ||
response: 1:02 AM |