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

Invalid duration when using partial object parameter in the creator #2633

Open
jalooc opened this issue Apr 18, 2024 · 1 comment · May be fixed by #2645
Open

Invalid duration when using partial object parameter in the creator #2633

jalooc opened this issue Apr 18, 2024 · 1 comment · May be fixed by #2645

Comments

@jalooc
Copy link

jalooc commented Apr 18, 2024

Describe the bug
The Duration creator returns incomplete duration if passed the object parameter that's partial:
image
image

Solution
Adding this.parseFromMilliseconds() in the constructor for the code branch handling the object parameter solves it:

    if (typeof input === 'object') {
      Object.keys(input).forEach((k) => {
        this.$d[prettyUnit(k)] = input[k]
      })
      this.calMilliseconds()
+     this.parseFromMilliseconds()
      return this
    }

Information

  • Day.js Version: 1.11.10
@iamkun
Copy link
Owner

iamkun commented Apr 27, 2024

Thanks for the great suggestion! Would you be open to submitting a pull request for this?

jalooc added a commit to jalooc/dayjs that referenced this issue Apr 28, 2024
…#2633)

The Duration creator returned incomplete duration if passed the object parameter that's partial.
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

Successfully merging a pull request may close this issue.

2 participants