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

Add p+ token support to parse function #1189

Merged
merged 4 commits into from Jun 10, 2019

Conversation

ericreis
Copy link
Contributor

@ericreis ericreis commented Jun 6, 2019

There's currently no way to parse date strings using long localized date/time formats. This PR aims to add support to p+ tokens to the parse function.

Added patterns:

Unit Prior Pattern Result examples Notes
Long localized date ? P 05/29/1453 7
PP May 29, 1453 7
PPP May 29th, 1453 7
PPPP Sunday, May 29th, 1453 2,5
Long localized time ? p 12:00 AM 7
pp 12:00:00 AM 7

and their combinations.

PS: Timezone time parses ppp and pppp were left out of this PR because the z+ parsers are not yet implemented in the locales.

@ericreis
Copy link
Contributor Author

ericreis commented Jun 6, 2019

@kossnocorp and @marnusw Can you take a look and check if this makes sense? This should close #896, or at least make it more consistent. Also, it should fix Hacker0x01/react-datepicker#1774.

Copy link
Member

@kossnocorp kossnocorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lovely addition, thank you! Please address my comments, and I think then it'll ready to go.

src/parse/index.js Outdated Show resolved Hide resolved
src/parse/index.js Outdated Show resolved Hide resolved
Copy link
Member

@kossnocorp kossnocorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, thank you!

@kossnocorp kossnocorp merged commit 16a08bc into date-fns:master Jun 10, 2019
@kossnocorp
Copy link
Member

This PR was released as v2.0.0-alpha.32: https://gist.github.com/kossnocorp/a307a464760b405bb78ef5020a4ab136#v200-alpha32

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

Successfully merging this pull request may close these issues.

None yet

2 participants