myusuf3 / delorean

Delorean: Time Travel Made Easy
http://delorean.rtfd.org/
MIT License
1.84k stars 128 forks source link

parser failling in RFC3339 format #94

Closed manugarri closed 8 years ago

manugarri commented 8 years ago

Im using google calendar API.

See the following example:

from delorean import parse
import dateutil.parser

#event from google calendar API:
event_str
>>>  '2016-07-01T11:00:00+02:00'  #This is July 1st 2016

#delorean parse swaps months and days
parse(event_str)
>>> Delorean(datetime=datetime.datetime(2016, 1, 7, 11, 0), timezone=pytz.FixedOffset(120)) 

#dateutil parser works fine
dateutil.parser.parse(event_str)
datetime.datetime(2016, 7, 1, 11, 0, tzinfo=tzoffset(None, 7200))
myusuf3 commented 8 years ago

You need to do the following for the correct behaviour.

capture('2016-07-01T11:00:00+02:00', dayfirst=False, yearfirst=True)

Since the default is dayfirst and yearfirst are True.

parse(event_str, dayfirst=False)

We can't rely on the way you ran the above test in cases where we are parsing ambiguous dates.