Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Date and Time Converter solution in Clear category for Date and Time Converter by vilenka06
import datetime
def date_time(time: str) -> str:
date = datetime.datetime.strptime(time, '%d.%m.%Y %H:%M')
h = 'hour' if date.hour == 1 else 'hours'
m = 'minute' if date.minute == 1 else 'minutes'
return f"{date:%-d %-B %-Y year %-H {h} %-M {m}}"
print("Example:")
print(date_time("01.01.2000 00:00"))
assert date_time("01.01.2000 00:00") == "1 January 2000 year 0 hours 0 minutes"
assert date_time("09.05.1945 06:07") == "9 May 1945 year 6 hours 7 minutes"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Jan. 15, 2023