X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=parse-xml.c;h=6c93ad1a534e1f6fc7e5bf4dae944eeb7032fd75;hb=adc92d6de2ee1c71e88b66fb9c41e52de8cf4ea1;hp=ea568f74084c183ae645b11ab2227c115254d7c3;hpb=99c111e34833bb7b8af2ad5a6494790191b18e2c;p=ext%2Fsubsurface.git diff --git a/parse-xml.c b/parse-xml.c index ea568f7..6c93ad1 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -106,14 +106,25 @@ static void divedate(char *buffer, void *_when) { int d,m,y; time_t *when = _when; + int success = 0; + success = tm.tm_sec | tm.tm_min | tm.tm_hour; if (sscanf(buffer, "%d.%d.%d", &d, &m, &y) == 3) { tm.tm_year = y; tm.tm_mon = m-1; tm.tm_mday = d; - if (tm.tm_sec | tm.tm_min | tm.tm_hour) - *when = utc_mktime(&tm); + } else if (sscanf(buffer, "%d-%d-%d", &y, &m, &d) == 3) { + tm.tm_year = y; + tm.tm_mon = m-1; + tm.tm_mday = d; + } else { + fprintf(stderr, "Unable to parse date '%s'\n", buffer); + success = 0; } + + if (success) + *when = utc_mktime(&tm); + free(buffer); } @@ -396,6 +407,8 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf) return; if (MATCH(".meandepth", depth, &dive->meandepth)) return; + if (MATCH(".duration", duration, &dive->duration)) + return; if (MATCH(".divetime", duration, &dive->duration)) return; if (MATCH(".divetimesec", duration, &dive->duration))