Skip to content

Conversation

KrohnusMelavea
Copy link

Previously did not support all date formats, now it does.

@BBlackwo
Copy link
Collaborator

Hi @KrohnusMelavea, thanks for the PR.

Would you mind adding a few unit tests please to show different date formats that now work that didn't before. Thanks!

@KrohnusMelavea
Copy link
Author

Added positive and negative tests for my new branch implementing the fixed date parse. How would you like me to create the tests for the existing implementation on your repository? I could branch off main, add similar tests to the current implementation to demonstrate it failing, then create a pull request for that second branch?

@KrohnusMelavea
Copy link
Author

image
Screenshot showing the new tests passing.

@BBlackwo
Copy link
Collaborator

Added positive and negative tests for my new branch implementing the fixed date parse.

Looks great, thanks!

How would you like me to create the tests for the existing implementation on your repository?

Feel free to just add those tests to this branch, maybe in a seperate it() block, and I'll just double check that they were failing with the old logic locally 👍

@BBlackwo BBlackwo linked an issue Apr 15, 2025 that may be closed by this pull request
@KrohnusMelavea
Copy link
Author

I added those new tests and hope that they're to your satisfaction.
image
All tests pass.

The date parser will now try to create a new Date() rather than checking for specific date regex
@BBlackwo BBlackwo force-pushed the fix-date-parsing-not-supporting-all-formats branch from b1d9c99 to a2d8291 Compare April 16, 2025 10:53
@BBlackwo
Copy link
Collaborator

Thanks for the tests @KrohnusMelavea! I cleaned the commits up a bit and will now merge and release.

@BBlackwo BBlackwo merged commit 17c77f1 into btroncone:master Apr 16, 2025
1 check passed
@BBlackwo
Copy link
Collaborator

🎉 This PR is included in version 19.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@BBlackwo
Copy link
Collaborator

I hope this doesn't have too much of a performance impact now that we're trying to instantiate a date rather than using regex.

If we get performance complaints then I think we might need to go back to a regex but perhaps a regex that supports more dates. There are some very thorough ones here https://stackoverflow.com/questions/15491894/regex-to-validate-date-formats-dd-mm-yyyy-dd-mm-yyyy-dd-mm-yyyy-dd-mmm-yyyy

@KrohnusMelavea
Copy link
Author

Hmm, it didn't cause any problems in our codebase. Let me know if it ends up being an issue, and I'd be more than happy to amend my implementation.

@BBlackwo
Copy link
Collaborator

BBlackwo commented Apr 16, 2025

OK sounds great 👌 Thanks again

@BBlackwo
Copy link
Collaborator

There is a flaw in this logic where numbers are sometimes treated as dates. See #275

@BBlackwo
Copy link
Collaborator

Decided to revert this change. See #285 for details.

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 this pull request may close these issues.

Deserialization of JSON object stored as string fails due to date format. restoreDates implementation is too loose
3 participants