Skip to content

Preserve datetime instants in Julian day conversion - #70

Open
antonsoo wants to merge 1 commit into
fitnr:masterfrom
antonsoo:fix/julian-datetime-instants
Open

antonsoo wants to merge 1 commit into
fitnr:masterfrom
antonsoo:fix/julian-datetime-instants

Conversation

@antonsoo

Copy link
Copy Markdown

julianday.from_datetime() adds the UTC offset instead of converting to UTC. For example, J2000 noon expressed at +05:30 is shifted by eleven hours. Minute and second fractions are also rounded prematurely, and microseconds are scaled as milliseconds. The reverse conversion loses fractional seconds and can raise an invalid-minute error near an hour boundary.

Convert aware inputs to UTC, calculate the day fraction without decimal rounding, and use timedelta to reconstruct the fractional day. Naive inputs keep the existing UTC assumption. Update the old rounded reference and allow for floating-point Julian-day precision in the existing datetime assertions.

All 149 tests pass with make cov on Python 3.10, 3.12 and 3.14; make pylint passes. Forward and reverse conversions agree with exact rational references across datetime's calendar range. Two recorded OMM epochs also produce the expected positions in compiled SGP4 across 40 timezone/time variants, within the precision of a floating-point Julian date.

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

Successfully merging this pull request may close these issues.

1 participant