Skip to content

Fix isValid, ignoreCase, and line-break parsing; deprecate time zone objects - #156

Merged
knowledgecode merged 16 commits into
masterfrom
develop
Nov 28, 2026
Merged

knowledgecode merged 16 commits into
masterfrom
develop

Conversation

@knowledgecode

Copy link
Copy Markdown
Owner

Summary

Bug fixes in parsing, the deprecation of time zone objects, internal refactors, and a documentation pass.

Fixes

  • isValid: reject a timeZone the runtime does not recognize unless the input (or defaultDate) supplies an offset, matching the Invalid Date that parse() already returns
  • parse: ignoreCase folds both sides with the locale's case rules (upper-case, then lower-case), so upper-cased Greek names, whose capitals drop the tonos, now match
  • compile: keep line breaks outside brackets as literal tokens; previously format() dropped them and the parser did not require them

Deprecation

  • Time zone objects (date-and-time/timezones/* and the date-and-time/timezone entry) are tagged @deprecated in favor of IANA name strings; they will be removed in the next major version. The generator in tools/timezone.ts emits the tag and the data is regenerated

Refactors

  • Add toZoneName() to normalize the timeZone option in one place
  • Use startsWith for prefix matches; share formatOffset() between Z and ZZ; detect -0 with Object.is(); unpack utils overloads without an IIFE

Build / tooling / CI

  • Use globSync from node:fs and drop the glob devDependency
  • tsconfig.json sets noEmit, so npm run ts is a plain tsc
  • Remove redundant ESLint, Vitest, and package.json files settings
  • Redeploy docs when public/ changes

Tests

  • New: ignoreCase across every locale, the day-of-week parser, Arabic-Indic numerals, hour token precedence, unknown time zones, line breaks outside brackets
  • Tidy: literal offset-bound inputs instead of mutating TZ, a duplicated ar test removed, typo fixes, per-zone test names

Docs

  • Fix incorrect examples and outputs (EDT/BST in August, weekday names, numeral results, missing day-of-week plugin, wildcard spacing, broken links)
  • Document SS/S semantics, hour ranges and precedence, offset range, Duration format tokens and sign, context-dependent month names, DST transitions, and plugin edge cases; the agent skill references are updated to match

Test plan

  • npm run lint, npm run ts, npm test pass
  • npm run build && npx vitest run tests/build passes
  • Each commit passes npm run ts, ESLint, and Vitest on its own (except the first, CI-only commit, whose type check needs the glob package that the second commit removes)

Node.js 22 ships globSync in node:fs, so the glob devDependency is no longer needed. Also factor the repeated entry-map construction into a helper and drop the needless g flags from the single-match replacements.
tsconfig emitted declarations only, which nothing uses since rollup builds the types; set noEmit there so a bare tsc only type-checks.
ESLint flat config already defaults sourceType to module and type-aware rules do not need the process global; src/ holds no .d.ts for coverage to exclude; npm always packs LICENSE and README.md.
Each caller unwrapped a TimeZone object with its own isTimeZone() ternary. Add toZoneName() to zone.ts and use it everywhere, so createTimezoneDate() and parse() take a plain zone name and isTimeZone() no longer needs to be exported.
Replace !str.indexOf(x) with str.startsWith(x), which states the intent and stops scanning at the first mismatch instead of searching the whole string.
ignoreCase only lower-cased both sides, so an upper-cased Greek name, whose capitals drop the tonos, never matched the accented locale string. Fold each side by upper-casing and then lower-casing it with the locale, and test that every locale reads its own upper-cased month, weekday, and meridiem names.
parse() returns Invalid Date when it has to read the input in a zone Intl does not know, but isValid() still returned true. Check the zone name unless the input or defaultDate supplies an offset, and drop the _index > 0 check that _length > 0 and _index === _length already imply.
The token regex lacked the s flag, so its catch-all . skipped line breaks: format() dropped them from the output and the parser did not require them in the input.
…t unpacking

Share one formatOffset() between the Z and ZZ formatters, detect -0 with Object.is(), and unpack the overloaded utils arguments without an IIFE.
Have the generator tag every time zone object, in timezones/* and in the timezone entry, with @deprecated pointing to its IANA name string, since the objects will be removed in the next major version. Regenerate the data, and silence no-deprecated in the specs that still exercise the objects.
Check the offset bounds of isValid() with literal inputs instead of formatting dates under a mutated TZ, remove a duplicated ar MMMM test, merge the hour12 and hour24 cases into loops and name the MMM cases after their input, fix the minites typo, and name each timezone test after its zone.
Correct New York and London outputs for August (EDT and BST, not EST and GMT), weekday names for 2025-08-23, the numeral parse results, and the 1970-01-01 migration output; add the day-of-week plugin where an example parses a weekday name; fix the wildcard space count, the add* links in the API index, the FormatterOptions import, the preparse result shape, and the transform() equivalence.
Describe how SS and S truncate on format and scale on parse, the hour12/hour24 ranges, hour token precedence, the offset range, Duration format tokens and sign placement, context-dependent month names, DST transitions in parse(), the local-time reading of the utils, and edge cases of the transform, ordinal, two-digit-year, and zonename plugins. Mirror the token and plugin details in the agent skill references.
@codecov

codecov Bot commented Nov 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.96%. Comparing base (c42cf72) to head (69c3dc7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #156      +/-   ##
==========================================
+ Coverage   98.88%   98.96%   +0.07%     
==========================================
  Files          77       77              
  Lines        1255     1251       -4     
  Branches      369      361       -8     
==========================================
- Hits         1241     1238       -3     
+ Partials       14       13       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@knowledgecode
knowledgecode merged commit 9d99579 into master Nov 28, 2026
6 checks passed
@knowledgecode
knowledgecode deleted the develop branch November 28, 2026 08:44
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