fix(adif): read 4-digit HHMM QSO times as HH:MM:00 on import - #235
Merged
Conversation
ADIF's Time type is HHMMSS *or* HHMM (seconds omitted). adifDateTimeToUtc left-padded the time to six digits, so a 4-digit HHMM value was misread as a right-aligned HHMMSS: 2359 became 00:23:59 instead of 23:59:00, silently shifting every QSO imported from a logger that omits seconds to the wrong time of day (and, near midnight, the wrong date). Pad on the right instead (append "00" seconds) and clip over-long values to six digits. Export the function and add pure-function tests covering HHMMSS, HHMM noon/midnight, and an unparseable date. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
ADIF's
Timetype isHHMMSSorHHMM(seconds omitted). When a logger emits a 4-digitTIME_ON/TIME_OFF, Nextlog imported it at the wrong time of day.adifDateTimeToUtcleft-padded the time to six digits:So
2359(23:59) was parsed as00:23:59,1230(12:30) as00:12:30, and so on. Every QSO imported from a logger that omits seconds landed at the wrong time — and a late-evening contact near midnight could even shift onto the wrong calendar day.4-digit times are valid ADIF (and appear in this repo's own parser fixtures, e.g.
<time_on:4>2359), so this silently corrupted real imports. WSJT-X-styleHHMMSSlogs were unaffected, which is likely why it went unnoticed.Solution
Pad on the right (append
"00"seconds) instead of the left, and clip over-long values to six digits:adifDateTimeToUtcis now exported (it was module-private) so it can be unit-tested as a pure function, and carries a doc comment explaining the HHMM/HHMMSS rule.The QRZ ADIF path (
src/lib/qrz.ts) already parses HHMM correctly (it slices left-to-right with seconds defaulting to 0), so no change was needed there.Testing
tests/adif-datetime.spec.ts: coversHHMMSS,HHMMat noon/midnight/23:59, and an unparseable date returningnull. Confirmed the two HHMM cases failed before the fix and pass after.npx playwright test adif-datetime adif-parse adif-generate— 28 passing.npm run typecheck,npm run lint,npm run build— all clean.Future follow-up
None required. The fix is isolated to the one conversion helper.