Skip to content

Commit

Permalink
fix(utilities/date-time-format): prevent "0 years" display (#18322)
Browse files Browse the repository at this point in the history
Co-authored-by: kennylam <[email protected]>
  • Loading branch information
janhassel and kennylam authored Jan 30, 2025
1 parent 9815eaf commit 0d507e8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/utilities/src/dateTimeFormat/relative-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const tests = [
['weeks', 1, 60 * 60 * 24 * 7],
['weeks', 3, 60 * 60 * 24 * 7],
['months', 1, 60 * 60 * 24 * 7 * 4],
['months', 11, 60 * 60 * 24 * 7 * 4],
['months', 12, 60 * 60 * 24 * 7 * 4],
['years', 1, 60 * 60 * 24 * 365],
['years', 2, 60 * 60 * 24 * 365],
];
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/dateTimeFormat/relative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function format(
return rtf.format(weeks * -1, 'weeks');
}

if (Math.abs(months) < 12) {
if (Math.abs(days) < 365) {
return rtf.format(months * -1, 'months');
}

Expand Down

0 comments on commit 0d507e8

Please sign in to comment.