replaced localised date string with babel module

Signed-off-by: Konrad <klux2@hs-mittweida.de>
This commit is contained in:
Konrad 2019-09-27 21:24:00 +02:00
parent 9255527662
commit 14535ba228

View file

@ -14,6 +14,7 @@ from typing import Any
from urllib.error import HTTPError
import telepot
from babel.dates import format_date
from googletrans import Translator
from telepot.aio import DelegatorBot
from telepot.aio.delegate import per_chat_id, create_open, pave_event_space
@ -193,13 +194,13 @@ class HSMensaW(telepot.aio.helper.ChatHandler):
async def send_essen(chat_id: int, sprache: Language = Language.GERMAN) -> None:
global datum, essen, essen_eng
if sprache == Language.GERMAN or sprache == Language.GERMAN_ENGLISH:
nachricht = "Speiseplan am %s:\n" % datum.strftime("%A, den %d. %B %Y")
nachricht = "Speiseplan am %s:\n" % format_date(datum, format="full", locale="de_DE")
for i in essen:
nachricht += "- " + str(i).replace(".", ",") + "\n\n"
await send_message(bot_obj=bot, chat_id=chat_id, msg=nachricht, parse_mode="markdown")
if sprache == Language.ENGLISH or sprache == Language.GERMAN_ENGLISH:
nachricht = "Menu on %s:\n" % datum.strftime("%A, %d %B %Y")
nachricht = "Menu on %s:\n" % format_date(datum, format="full", locale="en")
for i in essen_eng:
nachricht += "- " + str(i) + "\n\n"
await send_message(bot_obj=bot, chat_id=chat_id, msg=nachricht, parse_mode="markdown")
@ -390,8 +391,6 @@ message_log = open("msg.log", "a")
signal.signal(signal.SIGTERM, shutdown)
signal.signal(signal.SIGINT, shutdown)
#locale.setlocale(locale.LC_TIME, 'de_DE.UTF-8')
translator = Translator()
try: