diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-02-25 14:19:16 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-25 14:28:35 -0800 |
commit | e8d6d0e4de7071e1edb054f6b972bd01908ed20a (patch) | |
tree | edf02880577e6ef4ea2b6d5e28bacc7c904e6a21 /parse-xml.c | |
parent | ab7e877715edd87d8800d32919aff33d3abc35b1 (diff) | |
download | subsurface-e8d6d0e4de7071e1edb054f6b972bd01908ed20a.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 14 |
1 files changed, 13 insertions, 1 deletions
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) || |