From e8d6d0e4de7071e1edb054f6b972bd01908ed20a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 25 Feb 2013 14:19:16 -0800 Subject: parse-xml.c: add parsing for DivingLog divetime and depthavg I have a sample file where the time is given as minutes.seconds instead of minutes:seconds. Fixes #69 Signed-off-by: Dirk Hohndel --- parse-xml.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/parse-xml.c b/parse-xml.c index 19b419cf5..63278071a 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -359,7 +359,17 @@ static void sampletime(char *buffer, void *_time) static void duration(char *buffer, void *_time) { - sampletime(buffer, _time); + /* DivingLog 5.08 (and maybe other versions) appear to sometimes + * store the dive time as 44.00 instead of 44:00; + * This attempts to parse this in a fairly robust way */ + if (!strchr(buffer,':') && strchr(buffer,'.')) { + char *mybuffer = strdup(buffer); + char *dot = strchr(mybuffer,'.'); + *dot = ':'; + sampletime(mybuffer, _time); + } else { + sampletime(buffer, _time); + } } static void percent(char *buffer, void *_fraction) @@ -819,7 +829,9 @@ static int divinglog_dive_match(struct dive *dive, const char *name, int len, ch { return MATCH(".divedate", divedate, &dive->when) || MATCH(".entrytime", divetime, &dive->when) || + MATCH(".divetime", duration, &dive->dc.duration) || MATCH(".depth", depth, &dive->dc.maxdepth) || + MATCH(".depthavg", depth, &dive->dc.meandepth) || MATCH(".tanktype", utf8_string, &dive->cylinder[0].type.description) || MATCH(".tanksize", cylindersize, &dive->cylinder[0].type.size) || MATCH(".presw", pressure, &dive->cylinder[0].type.workingpressure) || -- cgit v1.2.3-70-g09d2