stevedonovan / chrono-english

Converting informal English dates (like `date` command) to chrono DateTime in Rust
MIT License
57 stars 14 forks source link

Considered using https://github.com/coreutils/gnulib/blob/master/lib/parse-datetime.y ? #12

Open scuzzycheese opened 4 years ago

scuzzycheese commented 4 years ago

It seems Coreutils has a very nice implementation of this that works super reliably? https://github.com/coreutils/gnulib/blob/master/lib/parse-datetime.y

evanjs commented 4 years ago

This is something I've been wondering since realizing https://github.com/uutils/coreutils does not yet have this feature (IIRC).

I've never been too familiar with parsers or lexers, and while I'm very happy this crate exists, I have run into some issues with parsing, most lately, e.g. <week-day> 12pm

This simply returns "bad date".

I also wonder if there's a way to leverage the lexing and etc work done in coreutils.

stevedonovan commented 2 years ago

Ah, a yacc grammar! When I was first wondering how date did its magic, I looked for a formal specification. So this crate makes it up. I think we can tighten things up a lot, and produce better error messages (for me bringing in a grammar would be a nuclear option, only if we cannot resolve issues. But it is a useful reference)