Adding weeks in duration plugin is broken
Describe the bug
I haven't upgraded since 1.11.7 because of various bugs, and this is the big one now:
Sample code:
const dayjs = require('dayjs')
dayjs.extend(require('dayjs/plugin/duration'))
const today = dayjs()
const twoWeeksFromNow = dayjs().add(dayjs.duration({weeks:2}))
console.log({today,twoWeeksFromNow})
(I have tried both week and weeks)
Here is what I get in 1.11.10:
❯ node ./dayjs-bug.js
{
today: M {
'$L': 'en',
'$d': 2023-10-16T17:38:24.875Z,
'$y': 2023,
'$M': 9,
'$D': 16,
'$W': 1,
'$H': 13,
'$m': 38,
'$s': 24,
'$ms': 875,
'$x': {},
'$isDayjsObject': true
},
twoWeeksFromNow: M {
'$L': 'en',
'$d': 2023-10-16T17:38:24.875Z,
'$y': 2023,
'$M': 9,
'$D': 16,
'$W': 1,
'$H': 13,
'$m': 38,
'$s': 24,
'$ms': 875,
'$x': {},
'$isDayjsObject': true
}
}
Expected behavior
I expect this calculation to happen similarly to how it does in 1.11.7:
❯ node ./dayjs-bug.js
{
today: M {
'$L': 'en',
'$d': 2023-10-16T17:41:20.524Z,
'$x': {},
'$y': 2023,
'$M': 9,
'$D': 16,
'$W': 1,
'$H': 13,
'$m': 41,
'$s': 20,
'$ms': 524
},
twoWeeksFromNow: M {
'$L': 'en',
'$d': 2023-10-30T17:41:20.524Z,
'$x': {},
'$y': 2023,
'$M': 9,
'$D': 30,
'$W': 1,
'$H': 13,
'$m': 41,
'$s': 20,
'$ms': 524
}
}
Information
- Day.js Version: 1.11.10
- OS: macOS 14.0
- Browser: Node in the CLI
- Time zone:
America/New_York
Possible duplicate of #2464
looks like #2583 addresses this issue, if I'm not mistaking
Any movement here? I'd like to be able to update from the older version.
I can confirm that this is still broken in 1.11.13. The most recent version where this works still seems to be 1.11.7.
These related issues have been around for over a year now, and surprisingly, the problems haven't been resolved.
These related issues have been around for over a year now, and surprisingly, the problems haven't been resolved.
Let's not be rude; the maintainers don't owe us anything.