From cd44aabb5f4f02ac290bd43579a029f09e915ad5 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sun, 10 Jan 2016 12:12:39 +0200 Subject: Support for imperial depth on worldmap export This will use the depth units from user preferences when exporting the worldmap. Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- save-html.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'save-html.c') diff --git a/save-html.c b/save-html.c index 64ce94f66..5fc5b000a 100644 --- a/save-html.c +++ b/save-html.c @@ -259,6 +259,29 @@ void put_HTML_time(struct membuffer *b, struct dive *dive, const char *pre, cons put_format(b, "%s%02u:%02u:%02u%s", pre, tm.tm_hour, tm.tm_min, tm.tm_sec, post); } +void put_HTML_depth(struct membuffer *b, struct dive *dive, const char *pre, const char *post) +{ + const char *unit; + double value; + struct units *units_p = get_units(); + + if (!dive->maxdepth.mm) { + put_format(b, "%s--%s", pre, post); + return; + } + value = get_depth_units(dive->maxdepth.mm, NULL, &unit); + + switch (units_p->length) { + case METERS: + default: + put_format(b, "%s%.1f %s%s", pre, value, unit, post); + break; + case FEET: + put_format(b, "%s%.0f %s%s", pre, value, unit, post); + break; + } +} + void put_HTML_airtemp(struct membuffer *b, struct dive *dive, const char *pre, const char *post) { const char *unit; -- cgit v1.2.3-70-g09d2