stevedonovan / chrono-english

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

Expose underlying duration parsing #11

Closed mmcclimon closed 2 years ago

mmcclimon commented 4 years ago

I am in the process of rewriting a log-searching program in Rust, which it takes arguments like --on 'Apr 1 13:00' --around '6 hours'. This crate worked a treat for --on, but I really would like access to the underlying duration argument, so I added it!

I thought about returning a Duration, but that's fraught (because you have to deal with daylight savings, and leap seconds, and so on), so instead it just returns an Interval, so that the user can decide what to do with it. (In our existing log searcher, for example, a month is always 30 days and a day is always 24 hours, which is fine for our needs.)