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

Incorrect output for years 1 BC though 99 AD #1

Open
bucaneer opened this issue Apr 5, 2024 · 0 comments
Open

Incorrect output for years 1 BC though 99 AD #1

bucaneer opened this issue Apr 5, 2024 · 0 comments

Comments

@bucaneer
Copy link

bucaneer commented Apr 5, 2024

The method getDateFromJulianDay passes the year value to the new Date() constructor, which has a documented legacy behavior with two-digit year values:

new Date() exhibits legacy undesirable, inconsistent behavior with two-digit year values; specifically, when a new Date() call is given a two-digit year value, that year value does not get treated as a literal year and used as-is but instead gets interpreted as a relative offset — in some cases as an offset from the year 1900, but in other cases, as an offset from the year 2000.

So dates dates that should have a year value from 0 through 99 (1 BC through 99 AD) are incorrectly rendered as 1900 through 1999.

Year value for the output Date object should instead be set using the setUTCFullYear() method.

Also, I think the package documentation should somehow make note of the date limits of the calculation. The Python package PyMeeus which appears to implement the same algorithm works for year values -1000 through 3000 (1001 BC through 3000 AD) and throws an exception otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant