Repository navigation
Fix UTC formatting at near-boundary second carries - #1157
Open
heathsanchez wants to merge 1 commit into
Open
heathsanchez wants to merge 1 commit into
heathsanchez wants to merge 1 commit into
Conversation
Member
|
Oh, that's a very bad behavior — thanks for letting me know! I'll plan to look at this sometime this week, and hopefully get it merged. I'll have to plan for a Skyfield release near the end of the month, I suppose. |
Author
|
No problem Brandon, it's a brilliant project- happy to help. Have a great week! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Rounding a UTC instant near the end of a minute can produce a civil second that does not exist. On current
master:utc_jpl()exhibits the same rollover problem at four decimal places, with59.99995and60.99995. These are formatting labels, not evidence that Skyfield's internal time calculations are incorrect.Cause and fix
_utc_seconds(offset)adds half a display unit before splitting the TAI seconds. Near the boundary, the fractional remainder can be just below 1.0 (for example,0.9999999999999976), then round up when_utc_tuple()adds it to an integer civil second. That last rounding happens after the leap-offset/calendar decision, yielding impossible:60or:61labels.This patch normalizes the near-integer carry before applying the leap-second offset, and adds native regression tests for ordinary-minute and leap-minute rollovers in ISO and JPL formatting. The change is limited to
skyfield/timelib.pyandskyfield/tests/test_timelib.py.Verification
31a6ed7584cd09b6e48e07546a4b5921e1cd5bb4: existing native suite 584/584 pass, but the new boundary witness fails.assay --batch skyfield.tests586/586 pass (Python 3.12, NumPy 1.26.4),pyflakes skyfieldclean, andgit diff --checkclean.The report and correction were prepared with AI assistance. The unchanged upstream source was used for the original-head reproduction, and native controls and tests were run before submission. The claim is limited to impossible UTC labels. Maintainer feedback on the near-carry threshold or a preferred alternative is welcome.