Skip to content

Handle TT2000 leap seconds and adjust unixtime mapping - #350

Merged
bryan-harter merged 2 commits into
lasp:mainfrom
bryan-harter:main
Oct 21, 2026
Merged

bryan-harter merged 2 commits into
lasp:mainfrom
bryan-harter:main

Conversation

@bryan-harter

Copy link
Copy Markdown
Member

No description provided.

bryan-harter and others added 2 commits October 19, 2026 10:00
breakdown_tt2000 carried a rolled-over second into the minute field, so
2016-12-31T23:59:60 came back as 23:60:00, which datetime rejects. The
31st-of-month style carry is dropped: the CDF library renders leap
seconds as second 60, and compute_tt2000 already accepts that.

_LeapSecondsfromJ2000 flagged the overflow bit for every value at or past
the next leap boundary rather than only the leap second itself. When a
scalar was broken down the loop broke early and the bit stayed clear, so
array input returned a different (broken) result than scalar input for
the same value. Restrict the flag to values assigned to that interval.

unixtime() now maps :60 to :59 plus one second, as unix time has no leap
seconds.
Break down TT2000 leap seconds as :59:60 and make unixtime handle them

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Leap-second boundary behavior still needs runtime regression validation before approval.

No open issues 🎉

What changed in this PR

Corrects leap-second handling in cdflib’s TT2000 conversions and Unix timestamp mapping.

Changes:

  • Preserves leap seconds as 23:59:60 during TT2000 breakdown.
  • Restricts leap-second detection to the applicable interval and maps leap seconds to the following Unix second.
  • Adds regression tests for scalar/array consistency, round-tripping, encoding, and Unix timestamps.
File Description
tests/​test_epochs.py Adds leap-second conversion regression tests.
cdflib/​epochs.py Corrects TT2000 breakdown and Unix timestamp mapping.

Review effort: Balanced

@bryan-harter
bryan-harter merged commit cf7553f into lasp:main Oct 21, 2026
12 of 13 checks passed
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.

2 participants