Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation mismatch for parsing strings in latest version #84

Closed
ParthGandhi opened this issue Mar 28, 2016 · 6 comments
Closed

Documentation mismatch for parsing strings in latest version #84

ParthGandhi opened this issue Mar 28, 2016 · 6 comments

Comments

@ParthGandhi
Copy link
Contributor

Theres a bug when parsing date strings in the latest release.

In a new virtual env:

$ pip install delorean
$ pip freeze
Babel==2.2.0
Delorean==0.6.0
humanize==0.5.1
python-dateutil==2.5.2
pytz==2016.3
six==1.10.0
tzlocal==1.2.2
wheel==0.24.0
>>> import delorean
>>> delorean.parse("2013-05-06")
Delorean(datetime=datetime.datetime(2013, 6, 5, 0, 0), timezone='UTC')

but the docs say that the output should be Delorean(datetime=datetime.datetime(2013, 5, 6), timezone='UTC') (which is the correct thing to do according to ISO 8601).

Installing python-dateutil==2.5.1 fixes the problem, but i'm not sure if the bug is in delorean or on their end.

@andremilk
Copy link

On the changelog for the python-dateutil==2.5.2 they say they fixed a bug regarding dayfirst and yearfirst.
https://github.com/dateutil/dateutil/blob/master/NEWS

dateutil/dateutil@2d42e04

Looking forward to know more about this.

@andremilk
Copy link

I got an error of "ValueError: month must be in 1..12" from dateutil

File "/usr/local/lib/python2.7/site-packages/pynamodb/models.py", line 394, in refresh
self._deserialize(item_data)
File "/usr/local/lib/python2.7/site-packages/pynamodb/models.py", line 1142, in _deserialize
setattr(self, name, attr_instance.deserialize(value))
File "/usr/local/lib/python2.7/site-packages/pynamodb/attributes.py", line 260, in deserialize
print parse(value).datetime
File "/usr/local/lib/python2.7/site-packages/delorean/interface.py", line 68, in parse
dt = capture(datetime_str, dayfirst=dayfirst, yearfirst=yearfirst)
File "/usr/local/lib/python2.7/site-packages/dateutil/parser.py", line 1170, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/usr/local/lib/python2.7/site-packages/dateutil/parser.py", line 580, in parse
ret = default.replace(**repl)
ValueError: month must be in 1..12
and repl = {u'hour': 22, u'month': 28, u'second': 20, u'microsecond': 600703, u'year': 2016, u'day': 3, u'minute': 38}

@alan-unravel
Copy link

+1 on this

@alan-unravel
Copy link

A quick fix for this to prevent breaks would be to set dayfirst's default value to False, also it is strange that they don't deal with yearfirst flag at all and ideally it should take priority since it was the default

@myusuf3
Copy link
Owner

myusuf3 commented Mar 31, 2016

I wont have time to look at this till monday, but I will fix it soon.

@ParthGandhi
Copy link
Contributor Author

Closing this as a duplicate of #87.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants