Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Convert to datetime format solution in Clear category for Date and Time Converter by frankiser
from datetime import datetime
def date_time(time: str) -> str:
# Convert first to datetime format
import datetime
fTime : datetime = datetime.datetime.strptime(time, '%d.%m.%Y %H:%M')
hours : str = " hours "
minutes : str = " minutes"
if fTime.hour == 1:
hours = " hour "
if fTime.minute == 1:
minutes = " minute"
readableTime : str = str(fTime.day) + fTime.strftime(" %B ") + str(fTime.year) + " year " + str(fTime.hour) + hours + str(fTime.minute) + minutes
return readableTime
if __name__ == '__main__':
print("Example:")
print(date_time('01.01.2000 00:00'))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert date_time("01.01.2000 00:00") == "1 January 2000 year 0 hours 0 minutes", "Millenium"
assert date_time("09.05.1945 06:30") == "9 May 1945 year 6 hours 30 minutes", "Victory"
assert date_time("20.11.1990 03:55") == "20 November 1990 year 3 hours 55 minutes", "Somebody was born"
print("Coding complete? Click 'Check' to earn cool rewards!")
April 21, 2020