Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
DateandTimeConverter.c solution in Clear category for Date and Time Converter by trudnopodobny
def date_time(time: str) -> str:
MONTHS = ((1, 'January'),
(2, 'February'),
(3, 'March'),
(4, 'April'),
(5, 'May'),
(6, 'June'),
(7, 'July'),
(8, 'August'),
(9, 'September'),
(10, 'October'),
(11, 'November'),
(12, 'December'))
array = []
for a in time:
array.append(a)
day = int(array[0]+array[1])
month = ''
nr = int(array[3]+array[4])
for a, b in MONTHS:
if nr == a:
month = b
year = int(array[6]+array[7]+array[8]+array[9])
hour = int(array[11]+array[12])
minutes = int(array[14]+array[15])
if hour == 1 and minutes == 1:
return str(day)+' '+month+' '+str(year)+' year '+str(hour)+' hour '+str(minutes)+' minute'
if hour == 1:
return str(day)+' '+month+' '+str(year)+' year '+str(hour)+' hour '+str(minutes)+' minutes'
if minutes == 1:
return str(day)+' '+month+' '+str(year)+' year '+str(hour)+' hours '+str(minutes)+' minute'
return str(day)+' '+month+' '+str(year)+' year '+str(hour)+' hours '+str(minutes)+' minutes'
Oct. 13, 2018