borni-dhifi / ummalqura

Python Hijri Umalqurra
5 stars 4 forks source link

Incorrect conversion for dates 1937-03-13 and earlier #4

Open snoopyjc opened 3 years ago

snoopyjc commented 3 years ago

Passing a date of 1937-03-13 or earlier gives a negative number for the result day.

Bad:

>>> h=HijriDate(1937, 3, 13, gr=True)
>>> h.__dict__
{'day_gr': 13, 'month_gr': 3, 'year_gr': 1937, 'year': 1355, 'month': 12, 'day':
 -51383, 'month_len': -51383, 'month_name': '?? ?????', 'day_name_en': 'Saturday',
'day_name': '?????', 'month_name_gr': 'March'}

Good:

>>> h=HijriDate(1937, 3, 14, gr=True)
>>> h.__dict__
{'day_gr': 14, 'month_gr': 3, 'year_gr': 1937, 'year': 1356, 'month': 1, 'day':
1, 'month_len': 29, 'month_name': '????', 'day_name_en': 'Sunday', 'day_name': 
'?????', 'month_name_gr': 'March'}
>>>
snoopyjc commented 3 years ago

Would be good if you went back to 1900-01-01 to match Excel

snoopyjc commented 3 years ago

Root cause: https://webspace.science.uu.nl/~gent0113/islam/ummalqura.htm

"The following Western-Islamic calendar converter is based on the Umm al-Qura calendar and is valid from 1356 AH (14 March 1937 CE) to 1500 AH (16 November 2077 CE). Outside this interval, the converter will give erroneous results."