Skip to content

Incorrect output for years 1 BC though 99 AD #1

@bucaneer

Description

@bucaneer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions