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

Migrate from hijri-converter to hijridate #1211

Merged
merged 1 commit into from
Feb 1, 2024
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
10 changes: 4 additions & 6 deletions dateparser/calendars/hijri_parser.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
from hijri_converter import convert
from hijridate import Gregorian, Hijri

from dateparser.calendars import non_gregorian_parser


class hijri:
@classmethod
def to_gregorian(cls, year=None, month=None, day=None):
g = convert.Hijri(
year=year, month=month, day=day, validate=False
).to_gregorian()
g = Hijri(year=year, month=month, day=day, validate=False).to_gregorian()
return g.datetuple()

@classmethod
def from_gregorian(cls, year=None, month=None, day=None):
h = convert.Gregorian(year, month, day).to_hijri()
h = Gregorian(year, month, day).to_hijri()
return h.datetuple()

@classmethod
def month_length(cls, year, month):
h = convert.Hijri(year=year, month=month, day=1)
h = Hijri(year=year, month=month, day=1)
return h.month_length()


Expand Down
6 changes: 3 additions & 3 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ Dependencies

* dateutil_'s module ``relativedelta`` for its freshness parser.
* convertdate_ to convert *Jalali* dates to *Gregorian*.
* hijri-converter_ to convert *Hijri* dates to *Gregorian*.
* hijridate_ to convert *Hijri* dates to *Gregorian*.
* tzlocal_ to reliably get local timezone.
* ruamel.yaml_ (optional) for operations on language files.

.. _dateutil: https://pypi.python.org/pypi/python-dateutil
.. _convertdate: https://pypi.python.org/pypi/convertdate
.. _hijri-converter: https://pypi.python.org/pypi/hijri-converter
.. _hijridate: https://pypi.python.org/pypi/hijridate
.. _tzlocal: https://pypi.python.org/pypi/tzlocal
.. _ruamel.yaml: https://pypi.python.org/pypi/ruamel.yaml

Expand Down Expand Up @@ -261,4 +261,4 @@ To be able to use them you need to install the `calendar` extra by typing:
>>> HijriCalendar('17-01-1437 هـ 08:30 مساءً').get_date()
DateData(date_obj=datetime.datetime(2015, 10, 30, 20, 30), period='day', locale=None)

.. note:: `HijriCalendar` only works with Python ≥ 3.6.
.. note:: `HijriCalendar` only works with Python ≥ 3.7.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"console_scripts": ["dateparser-download = dateparser_cli.cli:entrance"],
},
extras_require={
"calendars": ["hijri-converter", "convertdate"],
"calendars": ["hijridate", "convertdate"],
"fasttext": ["fasttext"],
"langdetect": ["langdetect"],
},
Expand Down