Skip to content

Determines date using a sliding window - #3

Closed
guillaumegarcia13 wants to merge 1 commit into
MaximBelov:masterfrom
guillaumegarcia13:patch-1
Closed

guillaumegarcia13 wants to merge 1 commit into
MaximBelov:masterfrom
guillaumegarcia13:patch-1

Conversation

@guillaumegarcia13

Copy link
Copy Markdown

To prevent a Y2K51-bug, date computation has been modified with a sliding window

To prevent a Y2K51-bug, date computation has been modified with a sliding window
@MaximBelov

Copy link
Copy Markdown
Owner

Thanks — this is already on master. The same sliding window went in with #4 (commit 7868735), so the code here is identical to what is shipping apart from a couple of words in the comment. Closing as merged in substance rather than stale.

@MaximBelov MaximBelov closed this Aug 13, 2026
@MaximBelov

Copy link
Copy Markdown
Owner

@guillaumegarcia13 — your fork has moved a good way ahead of this one and I would rather merge it than reimplement it.

Comparing guillaumegarcia13/master against master here:

  • 205 application identifiers against 193. New ones are 03 MTO GTIN, 716 NHRN AIC and the whole 7250–7259 block (date of birth, biological sex, name fields, person address, birth sequence).
  • You fixed the switch fall-through that made 46 identifiers throw, return undefined, or parse as their neighbour. I hit the same bug independently in Fix switch fall-through breaking 46 application identifiers, add full AI coverage and CI #6 — the fix turned out to be the same break in the same place, which is reassuring for both of us.
  • The GS1 JSON-LD extraction (extract_gs1_final.js) looks like the right direction for validating element values against the official regex, requires and excludes.

I ran this fork's suite against your parser: 203 specs, no failures, and nothing regressed — raw, the CommonJS export and the sliding date window are all still there.

Would you open a PR with your master? The only overlap with #6 is that one break, so the conflict is trivial whichever lands first.

For context on what is here now: #6 adds a spec that parses every supported identifier and checks each one comes back under its own AI, plus CI and npm publishing. Your additions would slot straight into that — the new 725x identifiers would just extend the table.

@MaximBelov

Copy link
Copy Markdown
Owner

@guillaumegarcia13 — rather than leave this waiting, I went ahead and added the identifier block myself: #9 takes the fork from 193 to 205 with 03, 716 and 7250-7259. The list came from your fork, and the PR says so.

One thing I did differently, because it looked like a bug worth not copying. guillaumegarcia13/master declares:

parseDate("7250", "DOB");

but 7250 is YYYYMMDD, and parseDate reads six digits. On your fork:

]C1725019850630  ->  ai 7250, date 2026-01-05
                 ->  plus a second element with ai "30"

The first six digits are taken as a two digit date, the sliding window then does what it does with month 85, and the leftover 30 is parsed as an AI of its own. It comes back as a successful parse with two elements, so nothing downstream notices. 7251 has the same shape — you have it on parseVariableLength, which at least returns the raw string intact.

So #9 adds a parseLongDate for the four digit year forms, with no century guessing and with month, day, hours and minutes validated. Worth pulling into your fork either way.

The rest of your fork is still ahead of this one in the direction that matters — the GS1 JSON-LD extraction is a better answer to element validation than anything here, and none of that is in #9. If you do open a PR for it, it is welcome.

For context on what landed meanwhile: 1.0.8 shipped the switch fall-through fix we both found, and there is now a spec that parses every supported identifier, so an identifier added without being wired up correctly fails the build.

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