combine
combine copied to clipboard
DateTime parser
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
?
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.