chatgpt week commencing calcualtor

This commit is contained in:
Jun-te Kim 2025-03-17 18:32:24 +00:00
parent 2fe9cf3d00
commit 5e4790e723

View file

@ -11,13 +11,10 @@ from etl.validator.validator import DomnaSharePointValidator
from datetime import datetime, timedelta
def previous_monday(date):
# If it's Monday, return the same date
if date.weekday() == 0:
return date.strftime("%d%m%y")
# Otherwise, find the previous Monday
previous_monday = date - timedelta(days=date.weekday())
return f"W.C. {previous_monday.strftime('%d.%m.%Y')}"
def previous_monday():
today = datetime.today()
last_monday = today - timedelta(days=today.weekday() + 7) # Go back to last week's Monday
return f"W.C. {last_monday.strftime('%d.%m.%Y')}"
WEEK_COMMENCING = os.getenv("WEEK_COMMENCING", previous_monday())