Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Date and Time Converter by book1978
from datetime import datetime
def date_time(time: str) -> str:
t = datetime.strptime(time, '%d.%m.%Y %H:%M')
return t.strftime(f"{t.day} %B %Y year {t.hour} hour{('s', '')[t.hour == 1]} {t.minute} minute{('s', '')[t.minute == 1]}")
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!")
Feb. 26, 2023