iamkun / iamkun/dayjs

dayjs constructor does not work with strict flag set to true.

Open
#1,784 4 comments 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**
```
const format = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
const inputDate = '1993-12-01T10:22:33.128Z';
const isDateValid = dayjs(inputDate, format, true).isValid(); // returns false
```
another example
```
dayjs("2021-01-26T14:25:04.871Z", "YYYY-MM-DDTHH:mm:ss.SSSZ", true) //doesn't work - returns invalid Date
moment("2021-01-26T14:25:04.871Z", "YYYY-MM-DDTHH:mm:ss.SSSZ",true) //works
```
please see https://github.com/iamkun/dayjs/issues/1358#issuecomment-774296660

**Expected behavior**
In the first example, isValid() should return true
In the second example, dayjs should behave in the same manner as moment.

**Information**
- Day.js Version 1.10.7
- OS: ubuntu nodejs
- Time zone: Central Daylight Time -06:00

Contributor guide

Open the contributing guide

Research direction

Start by running the reported dayjs constructor examples with the strict flag and compare their results with Moment. Trace the constructor's formatted-date parsing path, then add coverage for the ISO timestamp cases; done means both examples validate successfully and match the stated Moment 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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.