diff options
author | Robert C. Helling <helling@atdotde.de> | 2019-10-30 15:01:54 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-11-03 04:05:29 -0800 |
commit | a3a3913e1e8955da0dd65011b4c5e67803e2c4da (patch) | |
tree | 9cf1117f45b6e779e54bffa9d9604496c88148a7 /core/plannernotes.c | |
parent | f1e7adfedcbbd7b39ea5763efaf30d61453e902c (diff) | |
download | subsurface-a3a3913e1e8955da0dd65011b4c5e67803e2c4da.tar.gz |
Planner: Don't accumulate rounding errors in stop durations
When displaying segment or stop times in the planner notes, we always
round to the next full minute. This can mean for example that we
round down more often than rounding up with the result that the sum
of the segment times does not match the total runtime and can for example
lead to stops that are shown with 0min duration.
With this patch, we increase the reference time of the last display only
by the duration time actually shown. This way, the rounding errors don't
accumulate but having rounded down previously makes rounding up the next
time more propable.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/plannernotes.c')
-rw-r--r-- | core/plannernotes.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/plannernotes.c b/core/plannernotes.c index c72ac901a..0bfdbe7d5 100644 --- a/core/plannernotes.c +++ b/core/plannernotes.c @@ -375,7 +375,8 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d } put_string(&buf, "</tr>\n"); newdepth = dp->depth.mm; - lasttime = dp->time; + // Only add the time we actually displayed so rounding errors dont accumulate + lasttime += ((dp->time - lasttime + 30) / 60) * 60; } } if (gaschange_after || gaschange_before) { |