You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Years and months are types that depend on the current time. For example, what should the following print:
let a = Duration::days(365);println!("{}", a.num_years());
Well, it depends on whether or not the year is a leap year. Similarly, months have a variable number of days.
If you care about this date dependence, it would probably be best to construct Date objects corresponding to the times you are thinking about and then perform the relevant calculations around Date.year and Date.month.
If you just want to know "about how many years in this duration", it would be best to just use Duration.num_days() / 365.
Hi, I'm quite new to Rust and chrono library.
I checked the https://docs.rs/chrono/0.4.19/chrono/struct.Duration.html, but there's no
num_years()
ornum_months()
API in chrono::Duration.Is there any work around solution for this ?
The text was updated successfully, but these errors were encountered: