-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbirthday_app.py
More file actions
48 lines (33 loc) · 1.08 KB
/
Copy pathbirthday_app.py
File metadata and controls
48 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import datetime
def print_header():
print('----------------------')
print(' BIRTHDAY APP')
print('----------------------')
print()
def get_birthday_from_user():
print("When were you born? ")
year = int(input("Year [YYYY]: "))
month = int(input("Month [MM]: "))
day = int(input("Day [DD]: "))
birthday = datetime.date(year, month, day)
return birthday
def compute_days_between_dates(original_date, target_date):
this_year = datetime.date(target_date.year, original_date.month, original_date.day)
dt = this_year - target_date
return dt.days
def print_birthday_information(days):
if days < 0:
print("You had your birthday {} days ago this year.".format(-days))
elif days > 0:
print("Your birthday is in {} day.".format(days))
else:
print("Happy birthday!")
def number_of_days(args):
pass
def main():
print_header()
bday = get_birthday_from_user()
today = datetime.date.today()
number_of_days = compute_days_between_dates(bday, today)
print_birthday_information(number_of_days)
main()