Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Applications/Birthday Reminder/source-code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import datetime

def calculate_age(birthdate, current_date):
birth_year, birth_month, birth_day = map(int, birthdate)
current_year, current_month, current_day = map(int, current_date)

age = current_year - birth_year
if (current_month, current_day) < (birth_month, birth_day):
age -= 1

ordinal_suffix = {1: 'st', 2: 'nd', 3: 'rd', 11: 'th', 12: 'th', 13: 'th'}.get(age % 10 if not 10 < age <= 13 else age % 14, 'th')

return age, ordinal_suffix

current_date = datetime.date.today().strftime('%Y-%m-%d')
current_date_lst = current_date.split('-')
bday_log = [
Expand Down