From 1e7f1529d238a308a4f7d4ef5f4f91c3699b8d9a Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Mon, 26 Jul 2021 21:48:23 +0200 Subject: [PATCH] Support for 12hour format from config file for what_time_is_it intent --- intents/daily/date_and_time/intent.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/intents/daily/date_and_time/intent.py b/intents/daily/date_and_time/intent.py index 005e307..ca54783 100644 --- a/intents/daily/date_and_time/intent.py +++ b/intents/daily/date_and_time/intent.py @@ -1,9 +1,18 @@ +import time + import utils.intents_utils +from utils import config_utils def what_time_is_it(): + current_time = time.localtime() response = utils.intents_utils.get_response("what_time_is_it") - response.replace("{time}", "18:41") + + 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