chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Need Duration to represent time in months/years

Open codeslubber opened this issue 1 year ago • 3 comments

In reading around it seems that this was left out because years are not the same length nor are months.

The use case I am trying to support is a product that expires, or must be replaced, after 3 years. The precision is of course a non-issue in this use case. I am going to use the lifetime (Duration) to compute the Expiration by adding it to the Installation.

Yes I can just do it by multiplying types that are there.

It does seem that basic use cases should not be unexpressable.

codeslubber avatar Jun 06 '24 05:06 codeslubber

https://docs.rs/chrono/latest/chrono/struct.DateTime.html#method.checked_add_months?

djc avatar Jun 07 '24 07:06 djc

Something like java.time.Period or datetime.timedelta would still be useful. Also (de)serializing RFC 3339/iso 8601 durations

punkstarman avatar Apr 29 '25 12:04 punkstarman

See also jiff::Span.

djc avatar Apr 29 '25 13:04 djc