summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2013-06-19 19:04:28 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-21 08:10:18 -0700
commit81858167ac3f69e99a1108fa305f2865417e2b81 (patch)
tree81064f7dfe8259b3d5ee34239193781533b8444a /profile.c
parent03657ce6a93a5db746a0de948b87eda0bd76d842 (diff)
downloadsubsurface-81858167ac3f69e99a1108fa305f2865417e2b81.tar.gz
Round up times instead of down
When seeing that you have 0 min left, it looks kinda wierd, so rather round up instead of down. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/profile.c b/profile.c
index c3b266b9c..9f7d97d44 100644
--- a/profile.c
+++ b/profile.c
@@ -68,6 +68,7 @@ static void dump_pi (struct plot_info *pi)
}
#define ROUND_UP(x,y) ((((x)+(y)-1)/(y))*(y))
+#define DIV_UP(x,y) (((x)+(y)-1)/(y))
/*
* When showing dive profiles, we scale things to the
@@ -1167,7 +1168,7 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
if (entry->ndl) {
/* this is a safety stop as we still have ndl */
if (entry->stoptime)
- snprintf(buf, bufsize, _("%s\nSafetystop:%umin @ %.0f %s"), buf2, entry->stoptime / 60,
+ snprintf(buf, bufsize, _("%s\nSafetystop:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
depthvalue, depth_unit);
else
snprintf(buf, bufsize, _("%s\nSafetystop:unkn time @ %.0f %s"), buf2,
@@ -1175,7 +1176,7 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
} else {
/* actual deco stop */
if (entry->stoptime)
- snprintf(buf, bufsize, _("%s\nDeco:%umin @ %.0f %s"), buf2, entry->stoptime / 60,
+ snprintf(buf, bufsize, _("%s\nDeco:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
depthvalue, depth_unit);
else
snprintf(buf, bufsize, _("%s\nDeco:unkn time @ %.0f %s"), buf2,
@@ -1187,7 +1188,7 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
snprintf(buf, bufsize, _("%s\nIn deco"), buf2);
} else if (has_ndl) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nNDL:%umin"), buf2, entry->ndl / 60);
+ snprintf(buf, bufsize, _("%s\nNDL:%umin"), buf2, DIV_UP(entry->ndl, 60));
}
if (entry->cns) {
memcpy(buf2, buf, bufsize);