Update 03-birthday/convert.py

This commit is contained in:
William Mantly 2023-09-24 21:00:03 +00:00
parent 87f0577c1d
commit 7c7857a462

View File

@ -1,5 +1,26 @@
from datetime import datetime
def to_time( delta ):
months = int( delta.days/30 )
days = delta.days
hours = delta.days*24
minutes = delta.days*24*60
return 'months : {}, days : {}, hours : {}, and minutes : {}'.format( months, days, hours, minutes )
def age_to_time( age ): def age_to_time( age ):
pass delta = datetime.now() - datetime.now().replace( year=datetime.now().year-age )
return to_time( delta )
def birthday_to_time( birthday ): def birthday_to_time( birthday ):
pass birthday = datetime.strptime( birthday, "%Y-%m-%d" )
delta = datetime.now() - birthday
return to_time( delta )
age = int( input('How old are you? ') )
print( age_to_time(age) )
birthday = input( 'What is your birth date?(YYYY-MM-DD) ')
print( birthday_to_time(birthday) )