Skip to content

fix(relativeTime): use 1 for singular thresholds instead of the previous unit's value (#2956) - #3221

Open
anas510 wants to merge 1 commit into
iamkun:devfrom
anas510:fix/relative-time-singular-value
Open

anas510 wants to merge 1 commit into
iamkun:devfrom
anas510:fix/relative-time-singular-value

Conversation

@anas510

@anas510 anas510 commented Sep 18, 2026

Copy link
Copy Markdown

Fixes #2956, fixes #2695

Singular thresholds (m, h, d, M, y) have no diff unit, so fromNow() / humanize() reused the count computed for the previous unit. Locales or updateLocale configs that use %d in singular keys printed e.g. 28 month ago, 60 hour ago, or 30 month for a 1-month duration.

  • Thresholds without a diff unit now substitute 1, matching Moment (number || 1).
  • Default en output and all shipped locales are unchanged (no singular key uses %d, and function locales ignore the number for singular keys).
  • Added tests for fromNow/toNow and duration().humanize() with %d singular keys.

This branch has not been deployed

No deployments
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.

relativeTime outputs day value but month as unit (eg. 28d -> 28mo) humanize a duration returns month instead of days with updated locale

2 participants