-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbirthday2.py
68 lines (56 loc) · 1.61 KB
/
birthday2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python3
from datetime import date as dt
def tdminusbd(td, bd):
thirtyone = False
thirty= False
omonth = False
if bd.month in (1, 3, 5, 7, 8, 10, 12):
thirtyone=True
thrity=False
elif bd.month in (4, 6, 9, 11):
thirtyone=False
thrity=True
else:
# you weer born in feb
thirtyone=False
thrity=False
if thirtyone :
print ("there are 31 days in month ", str(bday.month))
elif thirty :
print ("there are 30 days in month ", str(bday.month))
else :
print ("there are 28 days in month ", str(bday.month))
if td.day >= bd.day :
days = td.day - bd.day
omonth = False
else :
omonth = True
if thirtyone :
days = td.day + 31 - bd.day
elif thirty :
days = td.day + 30 - bd.day
else :
days = td.day + 28 - bd.day
print ("thirtyone is ", str(thirtyone))
print ("thirty is ", str(thirty))
print ("owe month is ", str(omonth))
if omonth :
months = td.month - bd.month -1
else :
months = td.month - bd.month
years = td.year - bd.year
age = dt(years, months, days)
return (age)
today = dt.today()
print("Todays date is, ", today.day)
print("it is the month of, ", today.month)
print("the year is, ", today.year)
bday = dt(1966,1,29)
print (bday.year)
print (bday.month)
print (bday.day)
# tdminusbd(today,bday)
howold = tdminusbd(today,bday)
print ("you are ", howold.day, " days")
print (howold.month, " months")
print (howold.year, " years old.")