-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
44 lines (36 loc) · 1.32 KB
/
__init__.py
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
from mycroft import MycroftSkill, intent_file_handler
from mycroft.util.time import now_utc
import re
from tzlocal import get_localzone
class MuxlisaDateTime(MycroftSkill):
def __init__(self):
MycroftSkill.__init__(self)
self.display_tz = None
@intent_file_handler('what.time.is.it.intent')
def handle_time_date_muxlisa(self, message):
utt = message.data.get('utterance', "")
hour, minute = self.get_spoken_current_time(location=None)
if not hour or not minute:
return
self.log.warning("nimalar bo'ldi")
self.speak_dialog('time.current', data={
'minute': minute,
'hour': hour
})
def get_spoken_current_time(self, location=None,
dtUTC=None, force_ampm=False):
# Get a formatted spoken time based on the user preferences
dt = self.get_local_datetime(location, dtUTC)
if not dt:
return
return dt.hour, dt.minute
def get_local_datetime(self, location, dtUTC=None):
if not dtUTC:
dtUTC = now_utc()
tz = get_localzone()
if not tz:
self.speak_dialog("time.tz.not.found", {"location": location})
return None
return dtUTC.astimezone(tz)
def create_skill():
return MuxlisaDateTime()