mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Try to accept that life sometimes is in English
This commit is contained in:
parent
755e9aa0d3
commit
057135022f
@ -23,13 +23,18 @@ def demangle_date(date: str) -> Optional[datetime.datetime]:
|
||||
"dd. mon.yyyy, HH:MM
|
||||
"""
|
||||
saved = locale.setlocale(locale.LC_ALL)
|
||||
try:
|
||||
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}")
|
||||
|
Loading…
Reference in New Issue
Block a user