Skip to content

fix date codes#345

Merged
makrsmark merged 4 commits intoairframesio:masterfrom
makrsmark:bugfix/date-code
Mar 5, 2026
Merged

fix date codes#345
makrsmark merged 4 commits intoairframesio:masterfrom
makrsmark:bugfix/date-code

Conversation

@makrsmark
Copy link
Collaborator

@makrsmark makrsmark commented Mar 4, 2026

make convertDateTimeToEpoch be in a reasonable format

fix code/tests accordingly

Summary by CodeRabbit

  • New Features

    • Added support for two additional H1 message types (INR, WXR) in decoding outputs.
  • Bug Fixes

    • Fixed date interpretation to use day/month ordering, improving timestamp accuracy across labels.
    • Adjusted how message date is recorded in some flows to reduce inconsistent raw date values.
  • Tests

    • Updated expected timestamps across tests, added coverage for H1 INR, and removed a stale date assertion.

make convertDateTimeToEpoch be in a reasonable format

fix code/tests accordingly
@makrsmark makrsmark requested a review from kevinelliott March 4, 2026 23:31
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c3ba0ce1-f76d-4f3e-b0ef-045f6c809f9b

📥 Commits

Reviewing files that changed from the base of the PR and between aa25fd2 and 5b89861.

📒 Files selected for processing (1)
  • lib/plugins/Label_16_AUTPOS.ts

Walkthrough

This PR switches date interpretation from MMDDYY/MMDDYYYY to DDMMYY/DDMMYYYY across the core epoch converter, updates label plugins to pass DDMMYY inputs, and adjusts/adds tests and H1 message-type handling accordingly.

Changes

Cohort / File(s) Summary
Core Date Parsing Utility
lib/DateTimeUtils.ts
Reordered substring extraction so convertDateTimeToEpoch parses dates as DDMMYY/DDMMYYYY instead of MMDDYY/MMDDYYYY.
Label Plugins with Date Format Updates
lib/plugins/Label_15.ts, lib/plugins/Label_1M_Slash.ts, lib/plugins/Label_24_Slash.ts, lib/plugins/Label_16_AUTPOS.ts
Stop reconstructing MMDDYY; build and pass DDMMYY (reordered substrings / renamed vars) to DateTimeUtils.convertDateTimeToEpoch.
H1 Helper & Mappings
lib/utils/h1_helper.ts
Added INR and WXR message-type mappings; removed assignment that set raw.message_date from processDateCode for single-field cases.
Tests — Timestamp & Assertion Updates
lib/plugins/Label_1J_2J_FTX.test.ts, lib/plugins/Label_H1_FLR.test.ts, lib/plugins/Label_H1_WRN.test.ts, lib/plugins/Label_4J_POS.test.ts
Updated expected raw.message_timestamp values, renamed two H1_FLR tests, and removed one raw.message_date assertion.
Tests — New H1 INR Test
lib/plugins/Label_H1_INR.test.ts
Added a new unit test covering Label_H1 INR decoding with multiple field assertions (timestamp, day, eta_time, fuel_on_board, checksum, formatted items, remaining text).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • kevinelliott
  • andermatt64

Poem

🐇 I swapped the substrings, day before the month,
Epochs hop to new beats as tests do a little dance,
DD then MM, a tidy, quiet fix,
Parsers twitch their whiskers, timestamps realign,
A rabbit applauds — code hops without a glitch.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix date codes' directly relates to the core changes: swapping date format interpretation from MMDDYY to DDMMYY across multiple date-handling modules and updating corresponding tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/DateTimeUtils.ts`:
- Around line 56-63: convertDateTimeToEpoch currently assumes the incoming date
is DDMMYY or DDMMYYYY and mangles other formats (causing RangeError/NaN
downstream); update the function to be migration-safe by detecting common
incoming layouts (e.g., DDMMYY/DDMMYYYY, YYYYMMDD, and already-ISO or dashed
forms) and attempt parsing in order of likelihood: normalize 2-digit year to
4-digit, if date matches /^\d{8}$/ decide whether it's DDMMYYYY or YYYYMMDD by
checking a plausible year range (e.g., first four chars between 1900–2100) or
try both and pick the one where Date.parse(timestamp) yields a valid number, and
if none succeed return a clear error (or throw) rather than producing NaN;
reference the convertDateTimeToEpoch function and the timestamp/millis variables
to locate the change.

In `@lib/plugins/Label_H1_INR.test.ts`:
- Around line 13-29: The INR test is failing because plugin.decode(message)
returns decoded=false for the provided INR fixture; either update the fixture or
fix the INR decode path so this input is accepted. Locate the INR handler used
by plugin.decode and adjust its detection/parsing logic to accept strings like
'INR/ID91511S,,/DC04032026,143534/...' and populate decodeResult.decoded = true,
decoder.decodeLevel = 'partial' and the raw fields (tail, message_timestamp,
day, eta_time, fuel_on_board, checksum) plus remaining.text as asserted in the
test; alternatively, if the handler is correct, modify the test fixture to match
the exact format the INR parser expects so the assertions (decodeResult.decoded,
decoder.decodeLevel, raw.tail, raw.message_timestamp, raw.day, raw.eta_time,
raw.fuel_on_board, raw.checksum, formatted.items.length, remaining.text) become
valid.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 29942a1a-cc72-4d54-9324-24b6299b9706

📥 Commits

Reviewing files that changed from the base of the PR and between 163cf5d and 0b9ca2e.

📒 Files selected for processing (9)
  • lib/DateTimeUtils.ts
  • lib/plugins/Label_15.ts
  • lib/plugins/Label_1J_2J_FTX.test.ts
  • lib/plugins/Label_1M_Slash.ts
  • lib/plugins/Label_24_Slash.ts
  • lib/plugins/Label_4J_POS.test.ts
  • lib/plugins/Label_H1_FLR.test.ts
  • lib/plugins/Label_H1_INR.test.ts
  • lib/plugins/Label_H1_WRN.test.ts
💤 Files with no reviewable changes (1)
  • lib/plugins/Label_4J_POS.test.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/utils/h1_helper.ts (1)

413-415: ⚠️ Potential issue | 🟠 Major

Single-field /DC date is now silently dropped.

On Line 413-Line 415, valid date data (data.length === 1) is ignored. This causes raw decode data loss compared to prior behavior and can break consumers expecting date presence when timestamp cannot yet be derived.

💡 Proposed fix
 function processDateCode(decodeResult: DecodeResult, data: string[]) {
   if (data.length === 1) {
-    // noop?
+    // Preserve raw date when time component is not present yet
+    decodeResult.raw.message_date = data[0];
   } else if (data.length === 2) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/utils/h1_helper.ts` around lines 413 - 415, The branch handling date
components drops valid single-field `/DC` values: in lib/utils/h1_helper.ts
where the code branches on data.length (the `if (data.length === 1) { // noop? }
else if (data.length === 2) { ... }` block), change the noop to preserve and
normalize the single-field date instead of dropping it—reuse the same
parsing/assignment logic used for the two-field case (the `data` array
processing) to convert `data[0]` into the output date/DC field (or keep it as
the decoded date string if that’s the module’s convention) so consumers receive
the date when only one component is present; ensure you update the same output
variable/field that the two-field branch sets and add any minimal validation
used there.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@lib/utils/h1_helper.ts`:
- Around line 413-415: The branch handling date components drops valid
single-field `/DC` values: in lib/utils/h1_helper.ts where the code branches on
data.length (the `if (data.length === 1) { // noop? } else if (data.length ===
2) { ... }` block), change the noop to preserve and normalize the single-field
date instead of dropping it—reuse the same parsing/assignment logic used for the
two-field case (the `data` array processing) to convert `data[0]` into the
output date/DC field (or keep it as the decoded date string if that’s the
module’s convention) so consumers receive the date when only one component is
present; ensure you update the same output variable/field that the two-field
branch sets and add any minimal validation used there.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5de19aed-6852-4440-9117-2bb3cda8b043

📥 Commits

Reviewing files that changed from the base of the PR and between 0b9ca2e and aa25fd2.

📒 Files selected for processing (1)
  • lib/utils/h1_helper.ts

@makrsmark makrsmark merged commit e7155fb into airframesio:master Mar 5, 2026
5 of 6 checks passed
@makrsmark makrsmark deleted the bugfix/date-code branch March 5, 2026 02:38
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.

1 participant