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

DateTime parser #325

Open
Ploppz opened this issue Aug 20, 2021 · 1 comment
Open

DateTime parser #325

Ploppz opened this issue Aug 20, 2021 · 1 comment

Comments

@Ploppz
Copy link

Ploppz commented Aug 20, 2021

I would like to create a DateTime parser for arbitrary formats. Should I aim for a PR, or just implement it in my own source code?

How should it be done? At first I thought that I can leverage chrono::DateTime::parse_from_str, but since combine only works by looking at one token at a time, it seems impractical. I guess we would have to peek sufficiently far into the stream. chrono::DateTime::parse_from_str needs the input to only have the timestamp and nothing more. (edited)
I'm hesitant to start from scratch with parsing datetimes, but perhaps it will be necessary in this case.
Edit: on second thought it does seem entirely impractical to use chrono for this.
My question is then just: is a general datetime parser something you want in combine?

@Marwes
Copy link
Owner

Marwes commented Aug 23, 2021

A datetime parser would be out of scope for combine itself as it has to many variations (even if there are some standards) and is perhaps too complicated.

If you create a parser which only recognizes/tokenizes a datetime (does not need to be exact, just should not conflict with any other "token") and use https://docs.rs/combine/4.6.0/combine/fn.from_str.html you can use chrono to do the decoding itself.

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