iamkun / iamkun/dayjs

Incorrect work of inValid().

Open
#1,629 2 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**
Function isValid() worked incorrectly.
F.e.
https://codesandbox.io/s/friendly-bhabha-o755x?file=/src/index.js
![image](https://user-images.githubusercontent.com/54622440/132572288-3529e676-57b0-4756-b443-63d93356fca2.png)

1. As you can see, using a strict flag does not help me to validate the date correctly. Or strict flag work some another way, not as 'moment'?
Also, even if I recheck the examples from your site I receive another results:
![image](https://user-images.githubusercontent.com/54622440/132577083-968a9de1-bc77-4075-bcba-0a0423e22037.png)

2. Why do I have a different date in 'dayjs' and 'moment'. As you can see I did not set locale, but "moment" parsed input date like '2012-10-47' as 'Fri Jan 20 2012 00:00:00 GMT+02002', but 'dayjs' parsed the same input date as 'Thu, 15 Nov 2012 22:00:00 GMT'. Why so?

**Expected behavior**
1. const dayjsStrict = dayjs('2012-10-47', 'MMM D, YYYY', true); // false

**Information**
- Day.js Version [e.g. v1.10.6]
- OS: [e.g. Windows]
- Browser [e.g. chrome 93]
- Time zone: [e.g. GMT+3:00 DST (Minsk)]

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the isValid() behavior in the linked CodeSandbox with the strict parsing example and the input '2012-10-47'. Compare the Day.js and Moment results described in the issue; done means the strict example returns false and the intended parsing behavior is clarified or corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.