'Convert humanize time into UTC time using arrow python

I have time given in the following format.

'August 28, 2017 Mon  03:30 am -  04:00 am'

I would like to convert it to the following utc format using arrow.

time =[u'2017-08-28T03:30:00+00:00', u'2017-08-28T04:00:00+00:00']

I was able to do it with very complex string manipulation but I think there is a smart way to do it using arrow.



Solution 1:[1]

One of my friends was able quickly put it together and sent me this. Thought it might help others.

import arrow
from dateutil.parser import * 
t = 'Fri October 20 05:15 pm - 06:15 pm'
q = t.split('-')[0].strip()
x = t.split(' ')
x = ' '.join(x[:3]) +' '+ x[-2] + ' '+  x[-1]

arrow.get(parse(q)), arrow.get(parse(x))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Parshuram Thorat