scrapinghub / dateparser

python parser for human readable dates
BSD 3-Clause "New" or "Revised" License
2.53k stars 463 forks source link

Inconsistent return types between calendars. #125

Closed sardok closed 8 years ago

sardok commented 8 years ago

HijriCalendar and JalaliCalendar implement BaseCalendar. But these two classes' get_date function's return type differs. This should be fixed by defining an interface for BaseCalender.

redapple commented 8 years ago

True, the docs even show this explicitly:

>>> from dateparser.calendars.jalali import JalaliParser
>>> JalaliParser(u'جمعه سی ام اسفند ۱۳۸۷').get_date()
datetime.datetime(2009, 3, 20, 0, 0)
>>> from dateparser.calendars.hijri import HijriCalendar
>>> HijriCalendar(u'17-01-1437 هـ 08:30 مساءً').get_date()
{'date_obj': datetime.datetime(2015, 10, 30, 20, 30), 'period': 'day'}

I don't know Hijri so I can't say if 'period': 'day' is needed or not

waqasshabbir commented 8 years ago

<period> ::= <day> | <month> | <year> applies to both hijri and jalali calendar cases.

waqasshabbir commented 8 years ago

Fixed in #221