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

Digging into leap year bug and improvming tests #154

Merged
merged 2 commits into from
Mar 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions panoramix/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import functools
import hashlib
import json
import logging

from dateutil.parser import parse
from sqlalchemy.types import TypeDecorator, TEXT
Expand Down Expand Up @@ -45,6 +46,7 @@ def parse_human_datetime(s):
generated strings

>>> from datetime import date, timedelta
>>> from dateutil.relativedelta import relativedelta
>>> parse_human_datetime('2015-04-03')
datetime.datetime(2015, 4, 3, 0, 0)
>>> parse_human_datetime('2/3/1969')
Expand All @@ -55,12 +57,18 @@ def parse_human_datetime(s):
True
>>> date.today() - timedelta(1) == parse_human_datetime('yesterday').date()
True
>>> parse_human_datetime('one year ago').date() == (datetime.now() - relativedelta(years=1) ).date()
True
"""
try:
dttm = parse(s)
except:
cal = parsedatetime.Calendar()
dttm = dttm_from_timtuple(cal.parse(s)[0])
try:
cal = parsedatetime.Calendar()
dttm = dttm_from_timtuple(cal.parse(s)[0])
except Exception as e:
logging.exception(e)
raise ValueError("Couldn't parse date string [{}]".format(s))
return dttm


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'markdown>=2.6.2, <3.0.0',
'numpy>=1.9, <2',
'pandas==0.16.2, <0.17',
'parsedatetime>=1.5, <2.0.0',
'parsedatetime==2.0.0',
'pydruid>=0.2.2, <0.3',
'python-dateutil>=2.4.2, <3.0.0',
'requests>=2.7.0, <3.0.0',
Expand Down