stevedonovan / chrono-english

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

Track (and return) input granularity #32

Open MiniaczQ opened 1 month ago

MiniaczQ commented 1 month ago

I found this crate while looking for convenient human date(time) parser. I wanted to use this for filtering in a time range from..to.

The thing that's crucial for that is deciding the granularity the user is working at. Say I want to find everything from 2023, meaning I want everything from 2023.01.01 to 2023.12.31.

If we assume there is time involved, this becomes much more apparent. Find everything from jan -> from 2024.01.01 00:00:00.000 to 2024.01.31 23:59:59.999 Same for jan 1 -> from 2024.01.01 (00:00:00.000) to 2024.01.01 (23:59:59.999)

With that said, what I'd like to access is the highest unit type used in the date: year, month, day (, hour, minute, second) So that I can appropriately fill in all the fields below that granularity, with minimal or maximum values depending on the boundary it's for.