refactor to allow for multiple code locations
This commit is contained in:
29
apps/vinyl/src/utils.py
Normal file
29
apps/vinyl/src/utils.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import datetime
|
||||
|
||||
|
||||
def parse_date(dutch_date: str):
|
||||
# Create a dictionary to map Dutch month names to English
|
||||
dutch_to_english_months = {
|
||||
"januari": "January",
|
||||
"februari": "February",
|
||||
"maart": "March",
|
||||
"april": "April",
|
||||
"mei": "May",
|
||||
"juni": "June",
|
||||
"juli": "July",
|
||||
"augustus": "August",
|
||||
"september": "September",
|
||||
"oktober": "October",
|
||||
"november": "November",
|
||||
"december": "December",
|
||||
}
|
||||
|
||||
# Split the date and replace the Dutch month with its English equivalent
|
||||
day, dutch_month, year = dutch_date.split()
|
||||
english_month = dutch_to_english_months[dutch_month]
|
||||
|
||||
# Rebuild the date string in English format
|
||||
english_date = f"{day} {english_month} {year}"
|
||||
|
||||
# Parse the date using strptime
|
||||
return datetime.datetime.strptime(english_date, "%d %B %Y").date()
|
||||
Reference in New Issue
Block a user