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

Adding weeks in duration plugin is broken #2479

Open
manchicken opened this issue Oct 16, 2023 · 3 comments
Open

Adding weeks in duration plugin is broken #2479

manchicken opened this issue Oct 16, 2023 · 3 comments

Comments

@manchicken
Copy link

manchicken commented Oct 16, 2023

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
@TonyRL
Copy link

TonyRL commented Oct 17, 2023

Possible duplicate of #2464

@vad99lord
Copy link

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

@manchicken
Copy link
Author

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

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

3 participants