dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Adding weeks in duration plugin is broken

Open manchicken opened this issue 2 years ago • 6 comments

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

manchicken avatar Oct 16 '23 17:10 manchicken

Possible duplicate of #2464

TonyRL avatar Oct 17 '23 02:10 TonyRL

looks like #2583 addresses this issue, if I'm not mistaking

vad99lord avatar Apr 12 '24 15:04 vad99lord

Any movement here? I'd like to be able to update from the older version.

manchicken avatar Jul 14 '24 10:07 manchicken

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.

manchicken avatar Oct 08 '24 15:10 manchicken

These related issues have been around for over a year now, and surprisingly, the problems haven't been resolved.

AiraNadih avatar Oct 13 '24 20:10 AiraNadih

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.

manchicken avatar Oct 13 '24 21:10 manchicken