Корректное склонение времени

This commit is contained in:
parent 40e559512c
commit 35ba87e246
1 changed files with 17 additions and 1 deletions

View File

@ -78,7 +78,23 @@ def switchToListen():
# Переход на "Говорю время" и возвращаюсь в "Начало"
def switchToTime():
now = datetime.datetime.now()
speaker.speak(f"Сейчас {now.hour} часов, {now.minute} минут")
time = f'Сейчас {now.hour} '
if now.hour == 0 or 5 <= now.hour <= 20:
time += 'часов '
if now.hour == 1 or now.hour == 21:
time += 'час '
if 2 <= now.hour % 20 <= 4:
time += 'часАА ' # тянем слог
time += str(now.minute)
if now.minute % 10 == 1 and now.minute != 11:
time += ' минута'
elif 5 <= now.minute <= 20 or 25 <= now.minute <= 30 or 35 <= now.minute <= 40 or 45 <= now.minute <= 50 or 55 <= now.minute:
time += ' минут'
else:
time += ' минуты'
speaker.speak(time)
return "Начало"
def _precipitation_today_message(precipitations:list):