Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

humanize a duration returns month instead of days with updated locale #2695

Open
adchevrier opened this issue Jul 18, 2024 · 0 comments
Open

Comments

@adchevrier
Copy link

adchevrier commented Jul 18, 2024

Describe the bug

When updating the locale to change the 'a month' format to '1 month':

dayjs.updateLocale('en', {
  relativeTime: {
    future: 'in %s', past: '%s ago', s: '%d seconds',
    m: '%d minute', mm: '%d minutes',
    h: '%d hour', hh: '%d hours',
    d: '%d day', dd: '%d days',
    M: '%d month', MM: '%d months',
    y: '%d year', yy: '%d years'
  }
});

The humanize function does not work as expected.

dayjs.duration(1, "month").humanize() returns '30 month'
same for dayjs.duration(30, "days").humanize() and dayjs.duration("P1M").humanize()

I have tested the limits:

dayjs.duration(25, 'days').humanize()
'25 days'
dayjs.duration(26, 'days').humanize()
'26 month'
dayjs.duration(45, 'days').humanize()
'45 month'
dayjs.duration(46, 'days').humanize()
'1 month'

Expected behavior
It should return '1 month'

Information

  • Day.js Version 1.11.12
  • OS: windows
  • Browser Chrome 126
  • Time zone: CET
@adchevrier adchevrier changed the title humanize a duration returns month instead of days humanize a duration returns month instead of days with updated locale Jul 19, 2024
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

No branches or pull requests

1 participant