Repository navigation
Parse ISO dates strictly: fixed-width digits, plain decimal seconds - #52
Conversation
parseIsoDate read each field with sscanf %d / %lf, so it took "2026-1-5", signed fields, a space before the hour, and seconds written "1e1" or "0x10" -- none of which its header documents. Each field is now read as exactly its width in ASCII digits, and seconds as two digits with an optional decimal fraction. Text after an embedded NUL is rejected too. Closes #51 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the changes tightening parseIsoDate input validation.
No open issues 🎉
What changed in this PR
Tightens parseIsoDate to match its documented input formats, addressing issue #51 while preserving supported date and time forms.
Changes:
- Replaces
sscanfparsing with fixed-width ASCII digit checks and plain decimal seconds parsing. - Rejects trailing content after embedded NULs and adds malformed-input and fractional-seconds regression tests.
- Clarifies that fractional seconds are supported and failed parsing leaves the output unchanged.
| File | Description |
|---|---|
tests/test_time.cpp |
Adds rejection cases and fractional-seconds acceptance checks. |
src/orrery/time.hpp |
Clarifies the parser’s format and failure guarantees. |
src/orrery/time.cpp |
Implements strict field parsing and full-input validation. |
Review effort: Balanced
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Self-review rubric (Copilot review request did not register:
Out-of-diff observation: Summary: the change is green in CI, but the regression proof required by the merge gate could not be produced in this sandbox, so the PR is left open for a human to confirm FAIL→PASS locally. This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
|
Status re-check (a later dispatch cycle), with the PR still handed off:
To clear the gate locally: If that confirms FAIL→PASS, the PR is ready to squash-merge. This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
|
Review re-run in a third dispatch cycle. The PR remains handed off.
What unblocks the merge is the local FAIL→PASS check already given in the comment above ( This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
parseIsoDate(src/orrery/time.cpp) no longer usessscanf%d/%lf. Each field is read as exactly its width in ASCII digits (YYYY-MM-DD,HH:MM,SS), and seconds as two digits with an optional decimal fraction. Signed fields, short fields (2026-1-5), a space before the hour, and exponent or hex-float seconds (1e1,0x10) are now rejected, as the header already promised. Text after an embedded NUL is rejected too.15.3reads as the double nearest 15.3.src/orrery/time.hppnow also names the decimal-fraction seconds form (already accepted and tested) and that a failure leavesoutunchanged (already tested).tests/test_time.cppgains a section with 19 rejection cases from the issue and its neighbours, the embedded-NUL case, and three fractional-seconds acceptance checks. No existingCHECKwas changed.Every documented form (
README.md--dateexamples, theJentry,orrery --help'sYYYY-MM-DD[THH:MM[:SS]]) and every date the app writes (formatIsoDateuses%04d-%02d-%02d %02d:%02d:%02d) still parses. Onlysrc/orrery/changed; no data, tolerance,strata.refor workflow file is touched.Closes #51
Test plan
Data, ephemeris tests, render smoke testgreen on the PR head (runstest_timewith-Werror)cmakeandg++here, so the CI run on the exact head SHA is the anchor.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson