We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I was wondering if there would by any interest in supporting fractional days.
Chrono's .num_days() does not round the number of days. See this Rust playground.
.num_days()
A possible solution is to implement something like this:
pub trait FractionalDays { fn num_fractional_days(&self) -> f64; fn fractional_days(fractional_days: f64) -> Self; } impl FractionalDays for Duration { fn num_fractional_days(&self) -> f64 { let seconds_in_a_day = 24.0 * 3600.0; f64::from(self.num_seconds() as i32) / seconds_in_a_day } fn fractional_days(fractional_days: f64) -> Self { Duration::seconds((fractional_days * 24. * 60. * 60.).round() as i64) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I was wondering if there would by any interest in supporting fractional days.
Chrono's
.num_days()
does not round the number of days. See this Rust playground.A possible solution is to implement something like this:
The text was updated successfully, but these errors were encountered: