Skip to content

Commit

Permalink
Fixed issue with date of birth format
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Jul 19, 2024
1 parent 60b67bf commit 7f221d0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions helpers/datetimeHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def standardize_date_format(date_str):
return f"{day}/{month}/{year}"

@staticmethod
def date_format_with_day_of_week_and_age(date_str):
def date_format_with_age(date_str):
try:
# Try parsing the date as '%d/%m/%Y'
parsed_date = datetime.strptime(date_str, "%d/%m/%Y")
Expand All @@ -110,12 +110,11 @@ def date_format_with_day_of_week_and_age(date_str):
age = today.year - parsed_date.year - ((today.month, today.day) < (parsed_date.month, parsed_date.day))

# Manually format the date to include the day of the week, day without leading zero, full month name, and year
day_of_week = parsed_date.strftime('%A')
day = parsed_date.day # Day without leading zero
month = parsed_date.strftime('%B') # Full month name
year = parsed_date.year # Full year

return f"{day_of_week} {day} {month} {year} (aged {age})"
return f"{day} {month} {year} (aged {age})"

@staticmethod
def date_format_with_day_of_week(date_str):
Expand Down

0 comments on commit 7f221d0

Please sign in to comment.