#1806·luxon

fullwide/hanidec numberingSystem: digit matcher and decoder tables have drifted apart, causing silent data corruption

Author: manqingzhouCreated Sep 21, 2026Updated Sep 21, 2026

Describe the bug

src/impl/digits.js keeps two independently-authored representations per numbering system: a regex character class used to recognize a digit, and a code-point range/char array used to decode it. Two of these have drifted out of sync, and parseDigits() has no fail-closed branch, so a recognized-but-undecodable character silently corrupts the parsed value while the resulting DateTime/Duration still reports isValid: true:

  1. fullwide off-by-two. The matcher [0-9] accepts U+FF10–U+FF19 (all ten full-width digits), but the decoder range numberingSystemsUTF16.fullwide is [65296, 65303] (only up to U+FF17). Full-width 8/9 (U+FF18/U+FF19) match as digits but decode to nothing — they're silently dropped from the accumulator.
  2. Literal | inside the hanidec character class. The source string "[〇|一|二|三|四|五|六|七|八|九]" puts a literal | inside a character class (where it has no alternation meaning), so the compiled regex matches an ordinary pipe as a "digit." Meanwhile hanidecChars strips | when building the decode array, so hanidecChars.indexOf("|") returns -1, and value += -1 string-concatenates a literal "-1" into the parsed number.

To Reproduce

javascript
import { DateTime } from 'luxon';

const dt1 = DateTime.fromFormat('2018-01-01', 'yyyy-MM-dd', { numberingSystem: 'fullwide' });
console.log(dt1.year, dt1.isValid); // -> 201 true  (should be 2018, or Invalid)

const dt2 = DateTime.fromFormat('|', 'y', { numberingSystem: 'hanidec' });
console.log(dt2.year, dt2.isValid); // -> -1 true

Verified against the actual 3.7.2 source; output matches exactly.

Actual vs Expected behavior

Actual: 2018 parses to year 201 (the full-width 8 vanishes); a lone | parses to -1 — both report isValid: true with no invalidReason. Expected: either these characters decode correctly, or the parse should fail (isValid: false) rather than silently emitting a value the input never contained.

Desktop (please complete the following information):

  • Luxon version: 3.7.2 (current latest; verified against source at GitHub tag 3.7.2)
  • Node: v24.16.0

Additional context

Suggested fix:

  • Correct the fullwide decoder range to [65296, 65305].
  • Remove the literal pipes from the hanidec character class: "[〇一二三四五六七八九]".
  • Make parseDigits fail closed: if a matched character can't be resolved by any decoder table (or resolves to indexOf's -1 sentinel), return NaN for the whole parse instead of silently dropping/misinterpreting the character.
  • A regression test round-tripping all ten digits for every supported numberingSystem, plus explicit rejection tests for |/[/] under hanidec, would catch regressions here.