2022-07-19 22:58:59 +02:00
|
|
|
import datetime
|
2022-07-23 20:35:42 +02:00
|
|
|
import zoneinfo
|
2022-07-19 22:58:59 +02:00
|
|
|
|
2022-07-23 20:35:42 +02:00
|
|
|
__all__ = ["LOCAL_TIMEZONE", "int_to_weekday", "str_to_date"]
|
|
|
|
|
|
|
|
|
|
|
|
LOCAL_TIMEZONE = zoneinfo.ZoneInfo("Europe/Brussels")
|
2022-07-11 22:23:38 +02:00
|
|
|
|
|
|
|
|
2022-07-01 15:46:56 +02:00
|
|
|
def int_to_weekday(number: int) -> str: # pragma: no cover # it's useless to write a test for this
|
2022-06-21 18:44:47 +02:00
|
|
|
"""Get the Dutch name of a weekday from the number"""
|
|
|
|
return ["Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"][number]
|
2022-07-19 22:58:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
def str_to_date(date_str: str) -> datetime.date:
|
|
|
|
"""Turn a string into a DD/MM/YYYY date"""
|
|
|
|
return datetime.datetime.strptime(date_str, "%d/%m/%Y").date()
|