Repository navigation
Fix isValid, ignoreCase, and line-break parsing; deprecate time zone objects - #156
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
Summary
Bug fixes in parsing, the deprecation of time zone objects, internal refactors, and a documentation pass.
Fixes
timeZonethe runtime does not recognize unless the input (ordefaultDate) supplies an offset, matching theInvalid Datethatparse()already returnsignoreCasefolds both sides with the locale's case rules (upper-case, then lower-case), so upper-cased Greek names, whose capitals drop the tonos, now matchformat()dropped them and the parser did not require themDeprecation
date-and-time/timezones/*and thedate-and-time/timezoneentry) are tagged@deprecatedin favor of IANA name strings; they will be removed in the next major version. The generator intools/timezone.tsemits the tag and the data is regeneratedRefactors
toZoneName()to normalize thetimeZoneoption in one placestartsWithfor prefix matches; shareformatOffset()betweenZandZZ; detect-0withObject.is(); unpack utils overloads without an IIFEBuild / tooling / CI
globSyncfromnode:fsand drop theglobdevDependencytsconfig.jsonsetsnoEmit, sonpm run tsis a plaintscpackage.jsonfilessettingspublic/changesTests
TZ, a duplicatedartest removed, typo fixes, per-zone test namesDocs
SS/Ssemantics, 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 matchTest plan
npm run lint,npm run ts,npm testpassnpm run build && npx vitest run tests/buildpassesnpm run ts, ESLint, and Vitest on its own (except the first, CI-only commit, whose type check needs theglobpackage that the second commit removes)