diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-09-27 20:42:34 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-09-27 20:42:36 +0200 |
commit | da0e5e0222bf3a39a02f984bc0456e87b363ad3c (patch) | |
tree | 498dbea17e30a1da866d72884a6e211307692c6f | |
parent | 47290952ce5f7cbd1c105a1819004d2a1069087a (diff) |
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.
-rw-r--r-- | src/util.rs | 6 |
1 files 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 } |