iamkun / iamkun/dayjs

Add duration not working anymore

Open
#2,495 1 comment 0 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**
In the following code:

```
const duration = dayjs.duration({ weeks: 1 });
const initialDate = dayjs(date);
const result = initialDate.add(duration);
```

`initialDate` and `result ` resolve to the same date.

This happened after upgrading from dayjs `1.11.8` to `1.11.9` or `1.11.10`

**Expected behavior**
The `result` date is correctly calculated

**Information**
- Day.js Version [1.11.9+]
- OS: [OS X 14.0]-
- Time zone: [GMT+1]

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided dayjs.duration({ weeks: 1 }) and initialDate.add(duration) example on Day.js 1.11.9 or newer, then compare it with 1.11.8. The work is done when adding a one-week duration changes the date as expected and the regression is verified against the reported versions.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.