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

Big Bug!!!!!! Date acquisition exception and parsing time exception #2662

Open
smithyj opened this issue May 20, 2024 · 2 comments
Open

Big Bug!!!!!! Date acquisition exception and parsing time exception #2662

smithyj opened this issue May 20, 2024 · 2 comments

Comments

@smithyj
Copy link

smithyj commented May 20, 2024

Case:

dayjs(`0001-12-01 00:00:00`).get("year") // 1901
moment(`0001-12-01 00:00:00`).get("year") // 1,expected

Case:

dayjs(`0001-12-00 00:00:00`).get("year") // 1901
moment(`0001-12-00 00:00:00`).get("year") // NaN,expected

Case:

dayjs("1100-12-00 00:00:00").isValid() // true
moment("1100-12-00 00:00:00").isValid() // false,expected

Case:

dayjs("1100-00-00 00:00:00").isValid() // true
dayjs("1100-00-01 00:00:00").isValid() // true
moment("1100-00-00 00:00:00").isValid() // false,expected
moment("1100-00-01 00:00:00").isValid() // false,expected

Case:

dayjs("0000-00-00 00:00:00").isValid() // true
moment("0000-00-00 00:00:00").isValid() // false,expected

There are more cases with issues.

@mike-kaonashi
Copy link

Your cases of .isValid() API stuffs somehow not a bug, its a feature otherwise.
You can check the code, they are using the regex to check your input as below
/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/
I think .isValid() still cause some unexpected bugs cuz I faced some

@smithyj
Copy link
Author

smithyj commented May 20, 2024

@mike-kaonashi But .get() cases is return error

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

No branches or pull requests

2 participants