Try to accept that life sometimes is in English

This commit is contained in:
I-Al-Istannen 2020-05-08 22:10:43 +02:00
parent 755e9aa0d3
commit 057135022f

View File

@ -24,12 +24,17 @@ def demangle_date(date: str) -> Optional[datetime.datetime]:
"""
saved = locale.setlocale(locale.LC_ALL)
try:
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
try:
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
except locale.Error:
PRETTY.warning(
"Could not set language to german. Assuming you use english everywhere."
)
date = re.sub(r"\s+", " ", date)
date = date.replace("Gestern", _yesterday().strftime("%d. %b %Y"))
date = date.replace("Heute", datetime.date.today().strftime("%d. %b %Y"))
date = date.replace("Morgen", _tomorrow().strftime("%d. %b %Y"))
date = re.sub("Gestern|Yesterday", _yesterday().strftime("%d. %b %Y"), date, re.I)
date = re.sub("Heute|Today", datetime.date.today().strftime("%d. %b %Y"), date, re.I)
date = re.sub("Morgen|Tomorrow", _tomorrow().strftime("%d. %b %Y"), date, re.I)
return datetime.datetime.strptime(date, "%d. %b %Y, %H:%M")
except ValueError:
PRETTY.warning(f"Could not parse date {date!r}")