Timeline for Rusted days - a WolframAlfa port
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 7, 2020 at 19:38 | vote | accept | baduker | ||
Nov 7, 2020 at 19:38 | comment | added | baduker | Right, getting rid of overflow still doesn't remedy the date delta issue. I'll poke around the crate and if I can't find what I need, I'll take this to Stackoverflow. | |
Nov 7, 2020 at 19:25 | comment | added | htl |
No problem, @baduker. As far as stopping the overflows, you can just cast Utc::now().month() etc to i64 and your code won't panic any more, for example let month = Utc::now().month() as i64 - date.month() . This doesn't solve your issue though, because then this says that the difference between 31/12/2019 and 31/10/2020 is 1 year, -2 months. I am not sure if the relativedelta crate might be helpful? I've not used it and just reviewed the documentation, but it might be able to do what you need.
|
|
Nov 7, 2020 at 19:04 | comment | added | baduker | Thanks for the feedback! Glad to hear the code is proper Rust-like. Not so great to learn I've missed a few things. Guess, it's time to learn writing tests in Rust. :) By the way, any tips on dealing with the overflow issue? | |
Nov 7, 2020 at 17:43 | history | answered | htl | CC BY-SA 4.0 |