-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtime.py
More file actions
executable file
·84 lines (66 loc) · 1.96 KB
/
time.py
File metadata and controls
executable file
·84 lines (66 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8-*-
import random
import re
from datetime import datetime
WORDS = ["TIME"]
PRIORITY = 4
def weekdayConverter(weekday_integer):
if weekday_integer is 0:
string = "monday"
elif weekday_integer is 1:
string = "tuesday"
elif weekday_integer is 2:
string = "wednesday"
elif weekday_integer is 3:
string = "thursday"
elif weekday_integer is 4:
string = "friday"
elif weekday_integer is 5:
string = "saturday"
elif weekday_integer is 6:
string = "sunday"
return string
def monthConverter(month_integer):
if month_integer is 1:
string = "january"
elif month_integer is 2:
string = "february"
elif month_integer is 3:
string = "march"
elif month_integer is 4:
string = "april"
elif month_integer is 5:
string = "may"
elif month_integer is 6:
string = "june"
elif month_integer is 7:
string = "july"
elif month_integer is 8:
string = "august"
elif month_integer is 9:
string = "september"
elif month_integer is 10:
string = "october"
elif month_integer is 11:
string = "november"
elif month_integer is 12:
string = "december"
return string
def handle(text, mic, profile):
hour = datetime.now().time().hour
minute = datetime.now().time().minute
date = datetime.now().day
month = monthConverter(datetime.now().month)
weekday = weekdayConverter(datetime.now().weekday())
if "time" in text.lower():
message = "It's currently " + str(hour) +" " + str(minute)
else :
message = "Today is "+ str(month) + " " + str(date)
mic.say(message)
def isValid(text):
"""
Returns True if the input is related to the meaning of life.
Arguments:
text -- user-input, typically transcribed speech
"""
return bool(re.search(r'\b(date|time)\b', text, re.IGNORECASE))