fitnr / convertdate

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

Julian Date converstion wrong for astronomical years less than -4716 #39

Closed xayhewalo closed 3 years ago

xayhewalo commented 3 years ago

convertdate.julian.from_gregorian is incorrect for dates before January 23, 4717 BCE (Gregorian)

>>> convertdate.julian.from_gregorian(-4716, 1, 23)
(-4716, 3, 1)  # correct
>>> convertdate.julian.from_gregorian(-4716, 1, 22)
(-4715, 2, 31)  # wrong, February 31st
>>> convertdate.julian.from_gregorian(-4717, 1, 22)
(-4715, -8, -29)  # obviously wrong

After reading the code it looks like this is an intrinsic problem with the algorithm. Does convertdate not support dates before -4716? If so there should be a warning in the documentation.

edit: fixed the dates

fitnr commented 3 years ago

I can look into the algorithm more to see if there's a way to support such extreme dates. If not, I can add a warning. What's your use case for using the proleptic Gregorian calendar in this time frame? Knowing that might be helpful in drafting a warning.

xayhewalo commented 3 years ago

Making prehistoric timelines indifferent calendars. I.e the Dinosaurs became extinct ### years before the reform of the julian calendar, etc.