From da0e5e0222bf3a39a02f984bc0456e87b363ad3c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 27 Sep 2017 20:42:34 +0200 Subject: Do not write month adjusting with macro, but hand-craft This fixes a bug: The month gets adjusted here, which invalidates the result of the get_num_of_days_in_month() call,... so we must call it again and again while adjusting here. --- src/util.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util.rs b/src/util.rs index cd6e038..86437be 100644 --- a/src/util.rs +++ b/src/util.rs @@ -19,8 +19,10 @@ pub fn adjust_times_add(mut y: i64, mut mo: i64, mut d: i64, mut h: i64, mut mi: fix! { mi, 60, h } fix! { h , 24, d } - let adjust = get_num_of_days_in_month(y, mo); - fix! { d , adjust, mo } + while d > get_num_of_days_in_month(y, mo) { + d -= get_num_of_days_in_month(y, mo); + mo += 1; + } fix! { mo, 12, y } -- cgit v1.2.3