dayjs
dayjs copied to clipboard
Invalid duration when using partial object parameter in the creator
Describe the bug
The Duration creator returns incomplete duration if passed the object parameter that's partial:
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
Thanks for the great suggestion! Would you be open to submitting a pull request for this?