Skip to content

fix: read counter-word units in ja and zh locales - #81

Merged
dy merged 1 commit into
jkroso:masterfrom
zzoraemon043:fix/ja-zh-counter-units
Nov 25, 2026
Merged

dy merged 1 commit into
jkroso:masterfrom
zzoraemon043:fix/ja-zh-counter-units

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

The ja and zh locales miss the counter-word forms that are the usual way to write some durations, so these inputs come back wrong:

parse.unit = ja
parse('3日間')      // null, while 3週間, 3分間, 3秒間 and 3年間 already work
parse('3か月')      // null, only ヶ月 is listed
parse('3ヶ月間')    // null

parse.unit = zh
parse('3个月')      // null, 3月 reads as March in Chinese
parse('2个小时')    // null
parse('1年3个月', 'd') // 365.25, the months are dropped

Changes:

  • ja: add 日間, ヶ月間, and か月 / カ月 / ヵ月 with and without 間.
  • zh: add 个月, 个星期, 个小时.

Each alias sits next to its unit, so unit guessing order is unchanged.

Added a locale counter forms test; 13 of its assertions fail before the change. npm test: 188 pass.

ja: 日間, ヶ月間, and the か月/カ月/ヵ月 spellings (with and without 間).
zh: 个月, 个星期, 个小时.

Without them '3日間' and '3个月' parse to null and '1年3个月' drops the months.
@dy
dy merged commit cc516c6 into jkroso:master Nov 25, 2026
3 checks passed
zzoraemon043 added a commit to zzoraemon043/zzoraemon043 that referenced this pull request Nov 25, 2026
zzoraemon043 added a commit to zzoraemon043/zzoraemon043 that referenced this pull request Nov 25, 2026
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