I wrote a Python function that prints the number of days remaining in birthday of a user - the value of which is entered by the user. The code is as follows:
"""
Created on Thu Feb 20 16:01:33 2020
@author: hussain.ali
"""
import datetime as dt
import pytz
def days_to_birthday():
a = (input('Enter your birthday in YYYY, MM, DD format with the year being the current year:'))
td = dt.datetime.today()
#td2= td.replace(hour=0, minute =0, second =0, microsecond =0)
birthday = dt.datetime.strptime(a, '%Y,%m,%d')
days_to_birthday = birthday - td
print("There are", days_to_birthday, ' remaining until your next birthday!')
days_to_birthday()
This script or code works well except that it gives the number of days plus hours as well as minutes, seconds and even microseconds remaining until the next birthday.
The output seems like:
Enter your birthday in YYYY, MM, DD format with the year being the current year:2020,3,7
There are 15 days, 6:11:07.020133 remaining until your next birthday!
I want either only the days remaining to be displayed in the output OR the output as: There are 15 days, 6 hours, 11minutes, 07seconds, and 020133 microseconds remaining until your next birthday!
What one needs to do to attain the desired output? Please advise.