dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Invalid duration when using partial object parameter in the creator

Open jalooc opened this issue 10 months ago • 1 comments

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

jalooc avatar Apr 18 '24 17:04 jalooc

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

iamkun avatar Apr 27 '24 17:04 iamkun