Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistencies where 0 is involved when initialising from a string #881

Closed
dagda1 opened this issue Apr 24, 2020 · 5 comments · Fixed by #882
Closed

inconsistencies where 0 is involved when initialising from a string #881

dagda1 opened this issue Apr 24, 2020 · 5 comments · Fixed by #882
Labels

Comments

@dagda1
Copy link

dagda1 commented Apr 24, 2020

Describe the bug
Inconsistencies where 0 is involved

For example:

const m1 = dayjs('1970-07-05', 'YYYY-MM-DD').format('DD-MM-YYYY') // '05-07-1970'

assert(dayjs('1970-00-00', 'YYYY-MM-DD').isValid(), "should this be valid?")

const  m2 = dayjs('1970-00-00', 'YYYY-MM-DD').format('DD-MM-YYYY') // '30-11-1969'

const m3 = dayjs('0000-01-01', 'YYYY-MM-DD').format('DD-MM-YYYY') // '01-01-1900'

Expected behavior
I was surprised that this code was true

assert(dayjs('1970-00-00', 'YYYY-MM-DD').isValid(), "should this be valid?")

Is this a bug or expected behaviour?

Information
version - 1.8.23
os - osx

@iamkun
Copy link
Owner

iamkun commented Apr 24, 2020

This is valid to new Date()

We might need a strict mod to better handle this problem?

@dagda1
Copy link
Author

dagda1 commented Apr 24, 2020

@iamkun just what I was going to suggest. At least I know now though. Thanks

@dagda1
Copy link
Author

dagda1 commented Apr 29, 2020

@iamkun is #882 something I can now use?

@iamkun
Copy link
Owner

iamkun commented Apr 30, 2020

Will release soon @dagda1

@iamkun
Copy link
Owner

iamkun commented Apr 30, 2020

🎉 This issue has been resolved in version 1.8.26 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants