This repository has been archived on 2023-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
jarvis-server/skills/daily/date_and_time/intent.py

31 lines
810 B
Python
Raw Normal View History

import time
2021-07-26 22:07:51 +02:00
from datetime import datetime
2021-07-26 22:07:51 +02:00
from utils import config_utils, intents_utils
2021-07-26 18:23:32 +02:00
def what_time_is_it():
2021-07-26 22:07:51 +02:00
tag = 'what_time_is_it'
response = intents_utils.get_response(tag)
current_time = time.localtime()
if config_utils.get_in_config("12HOURS-FORMAT"):
response = response.replace('{time}', time.strftime("%I:%M %p", current_time))
else:
response = response.replace('{time}', time.strftime("%H:%M", current_time))
return response
2021-07-26 18:23:32 +02:00
def what_day_is_it():
2021-07-26 22:07:51 +02:00
tag = 'what_day_is_it'
response = intents_utils.get_response(tag)
day_number = datetime.today().weekday()
lang_json = intents_utils.get_lang_for_intent('what_day_is_it')['others']['days_of_week']
response = response.replace('{day}', lang_json[str(day_number)])
return response