iamkun / iamkun/dayjs

Duration is wrong on 1.11.10

Open
#2,464 7 comments 7 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The duration is wrong.

Let's take this example

```javascript
// Init
const dayjs = require('dayjs')
const duration = require( 'dayjs/plugin/duration');

dayjs.extend(duration);

// two dates
const first = dayjs('2020-01-01T12:00:00.000Z')
const start = dayjs('2020-01-01T12:00:00.000Z').subtract(10, 'weeks')

// compute duration
const milliseconds = first.diff(start, 'milliseconds')
dayjs.duration(milliseconds).toISOString()
```

With dayjs 1.11.09, we get 'P2M10DT1H'
With dayjs 1.11.10 we get 'P2M9DT5H' which I don't even understand

**Expected behavior**

Previous behavior is right

**Information**
- Day.js Version 1.11.09 vs 1.11.10

Contributor guide

Open the contributing guide

Research direction

Start with the supplied JavaScript reproduction using dayjs/plugin/duration and compare 1.11.09 with 1.11.10. Trace the duration conversion responsible for toISOString(); done means restoring the expected P2M10DT1H result without regressing the prior behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.