fitnr / convertdate

Utils for converting between date formats and calculating holidays
MIT License
47 stars 24 forks source link

Bahá'í date is not working during Ayyám-i-Há #13

Closed eliheuer closed 5 years ago

eliheuer commented 5 years ago

Today is the first day of Ayyám-i-Há, but when I run the following script:

import datetime
from convertdate import bahai

now = datetime.datetime.now()
bahai_date = bahai.from_gregorian(now.year, now.month, now.day)
print("Bahá'í Date: ", bahai_date)

I get the first day of the 19th month as a result:

Bahá'í Date:  (175, 19, 1)

Ayyám-i-Há is a period of intercalary days, and the 19th month should start after Ayyám-i-Há. There are 19 months with 19 days, so 19*19=361, Ayyám-i-Há just fills the gap between 361 days and the total number of days depending on if it is a leap year or not.

bchurchill commented 5 years ago

It's a little more complicated than this since the Universal House of Justice implemented the Badi calendar (in 2014 I think?). Now the date of Naw Ruz varies between March 20th and March 21st and I don't think the current implementation handles this.

(On the other hand, I think Ayyam-i-Ha might be OK, if the month of 'Ala corresponds to "month" 20, and Ayyam-i-Ha is "month" 19. The source code seems to work this way. Perhaps only better documentation is needed for this.)

bchurchill commented 5 years ago

I'll try working on this as time permits.

fitnr commented 5 years ago

Fixes in the above commit