olliemath / chronoutil

ChronoUtil module provides powerful extensions to rust's Chrono crate.
MIT License
21 stars 9 forks source link

Compatibility with time #4

Open olliemath opened 1 year ago

olliemath commented 1 year ago

Some folks bypass Chrono altogether and instead use https://github.com/time-rs/time since it has gained a reputation for being more actively maintained.

It would be worth exploring whether to make this library compatible with both, or to spin out a subset compatible with time which does not have a chrono dependency.

olliemath commented 1 year ago

Notes:

While this is definitely possible, it will be tedious to write because time does not have a concept of a DataLike trait. That means writing a different function for each of the different Date types in the time crate.

Probably it would be cleaner just to write a separate library for this and split out any "core" functions that are needed, or implement as a separate chronoutil::time namespace that does not pull in any chrono dependencies.

While I'd love to implement something like RelativeDuration<T> with T "duration-like", I think due to the incompatibility between the time and chrono ecosystems, keeping it simple with two completely separate RelativeDuration types will be easier.

olliemath commented 1 year ago

More notes:

Because time lacks anything like Datelike, we may have to impl our own trait in order to get it to work? Unsure how they are implementing their own add with duration, maybe I should ask them for some implementation tips..