Skip to content

Conversation

@ChristopherRabotin
Copy link
Member

Previously, one could initialize an Epoch with the 60th second on a leap day even if the selected time scale did not support leap seconds. This PR makes this an error.

Importantly, this PR also fixes an error in the julian_epoch test where an epoch was initialized on the leap second but ... in TAI. There is no leap second in TAI, so this initialization should fail. The test case was also expanded to confirm the computation of Modified Julian Dates using NASA HEASARC, with an extra test and a clarification that leap second management is implementation dependent.

Thanks for the report @ephraim71 !

Previously, one could initialize an Epoch with the 60th second on a leap
day even if the selected time scale did not support leap seconds.
This PR makes this an error.

Importantly, this PR also fixes an error in the `julian_epoch` test
where an epoch was initialized on the leap second but ... in TAI.
There is no leap second in TAI, so this initialization should fail.
The test case was also expanded to confirm the computation of Modified
Julian Dates using NASA HEASARC, with an extra test and a clarification
that leap second management is implementation dependent.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @ChristopherRabotin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of time handling within the Epoch system by enforcing stricter validation during initialization, specifically concerning leap seconds in non-leap-second time scales. It also refines and expands the test suite to ensure the accuracy of Modified Julian Date (MJD) calculations and to explicitly test for invalid date inputs, improving overall reliability.

Highlights

  • Time Scale Validation: I've implemented a check within the Epoch::from_gregorian_hms constructor to prevent initialization with a 60th second (representing a leap second) if the specified TimeScale does not support leap seconds. This now correctly returns an InvalidGregorianDate error in such cases.
  • Leap Second Test Correction and Expansion: I've corrected the julian_epoch test by switching from TAI (International Atomic Time, which does not have leap seconds) to UTC (Coordinated Universal Time, which does) for leap second related MJD calculations. Additionally, I've expanded these tests to include verification against NASA HEASARC data and added clarifying comments regarding the implementation-dependent nature of leap second handling.
  • New Regression Tests: I've added two new #[should_panic] tests. One specifically validates that attempting to initialize an Epoch with 60 seconds in a non-leap-second time scale (like TAI) correctly panics. The other confirms that initializing an Epoch with an invalid Gregorian date (e.g., February 31st) also results in a panic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adds a check to prevent initializing an epoch with a leap second for time scales that do not support them. The tests are updated accordingly, including fixing a bug in an existing test and adding a new regression test. My review focuses on improving test code maintainability by removing a duplicated test and a magic number.

@codecov
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.68%. Comparing base (6b1ebba) to head (8559a25).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #411   +/-   ##
=======================================
  Coverage   82.68%   82.68%           
=======================================
  Files          24       24           
  Lines        3569     3570    +1     
=======================================
+ Hits         2951     2952    +1     
  Misses        618      618           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChristopherRabotin
Copy link
Member Author

I've reviewed the changes "à tête reposée" and agree with them, so I'll go ahead and merge this.

@ChristopherRabotin ChristopherRabotin merged commit b23307c into master Aug 2, 2025
30 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