Skip to content
New issue

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

Add methods for float multiplication/division #1365

Open
JamesGuthrie opened this issue Nov 22, 2023 · 1 comment
Open

Add methods for float multiplication/division #1365

JamesGuthrie opened this issue Nov 22, 2023 · 1 comment

Comments

@JamesGuthrie
Copy link

JamesGuthrie commented Nov 22, 2023

It would be very convenient to have the methods mul_f32, mul_f64, div_f32 and div_f64, which are available on std::time::Duration available on chrono::Duration.

To be clear it is possible to round-trip through std::time::Duration which I'm currently doing:

let duration = chrono::Duration::from_secs(2);
let multiplier = 0.5;
let half_duration: chrono::Duration = chrono::Duration::from_std(duration.to_std().unwrap().mul_f64(multiplier)).unwrap();

But it would be nicer to do this:

let duration = chrono::Duration::from_secs(2);
let multiplier = 0.5;
let half_duration = duration.mul_f64(multiplier);
@djc
Copy link
Member

djc commented Nov 22, 2023

Sounds reasonable, if you submit a PR against the 0.4.x branch I'll review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants