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

CatchInvalid Date error and display given value instead #2

Merged

Conversation

marcoroth
Copy link
Contributor

@marcoroth marcoroth commented Nov 5, 2020

Hey @guillaumebriday,

It seems like that some browsers see 2018-01-30 09:00 as an invalid date.
Technically speaking it's not a valid ISO 8601 timestamp. But it seems that some browsers are somewhat generous to treat it as a valid timestamp.

However, this PR fixes the timestamp and shows the given input on a validation error! 😊

@marcoroth
Copy link
Contributor Author

Maybe it could be worth to catch this error and display given timestamp instead of showing nothing 🤔

@guillaumebriday
Copy link
Member

Nice catch @marcoroth! Thanks 🙏

Could your please update the readme too?

Update README with the reflected changes
@marcoroth
Copy link
Contributor Author

Sure! I updated the README and added a catch block in the controller which will show the given value on a parse error.

Previously it looked like this:

Stimulus 1.0.0 was released . 

Now it looks like this:

Stimulus 1.0.0 was released 2018-01-30 09:00.

It's not perfect, but it's better than showing nothing.

@marcoroth marcoroth changed the title fix netlify demo to not throw an Invalid Date error CatchInvalid Date error and display given value instead Nov 5, 2020
src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
@guillaumebriday
Copy link
Member

thanks @marcoroth!! Will merge tomorrow 👍

@guillaumebriday guillaumebriday merged commit 3a81c6b into stimulus-components:master Nov 6, 2020
@marcoroth marcoroth deleted the fix-invalid-date branch November 11, 2020 15:04
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

Successfully merging this pull request may close these issues.

None yet

2 participants