-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbirthday.py
42 lines (32 loc) · 1.09 KB
/
birthday.py
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
import datetime
def print_header():
print('------------------------------')
print(' Birthday CountDown ')
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 computer_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 {} days".format(days))
else:
print("Happy birthday!!!")
def main():
print_header()
bday = get_birthday_from_user()
print(bday)
now = datetime.date.today()
number_of_days = computer_days_between_dates(bday, now)
print_birthday_information(number_of_days)
main()