From 8426024b76ebc6e3aa3def24aa077a5b7442347c Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 25 Sep 2018 15:35:47 -0700 Subject: Allow XML sample times to have hh:mm:sec format We traditionally only allow samples to have a time format of 'mm:ss', so if you have a dive over an hour, you would just have a minutes field larger than 60 minutes. But Matthew Critchley is trying to import some dives from his VMS Redbare CCR, and the sample timestamp format he has is of the type 'hh:mm:ss'. That could be fixed by a xslt translation, but there's no real reason why we couldn't just support that format too. Reported-by: Matthew Critchley Signed-off-by: Linus Torvalds --- core/parse-xml.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/parse-xml.c b/core/parse-xml.c index dd2250d21..2577d6380 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -322,16 +322,21 @@ static void temperature(char *buffer, temperature_t *temperature) static void sampletime(char *buffer, duration_t *time) { int i; - int min, sec; + int hr, min, sec; - i = sscanf(buffer, "%d:%d", &min, &sec); + i = sscanf(buffer, "%d:%d:%d", &hr, &min, &sec); switch (i) { case 1: - sec = min; - min = 0; + min = hr; + hr = 0; /* fallthrough */ case 2: - time->seconds = sec + min * 60; + sec = min; + min = hr; + hr = 0; + /* fallthrough */ + case 3: + time->seconds = (hr * 60 + min) * 60 + sec; break; default: printf("Strange sample time reading %s\n", buffer); -- cgit v1.2.3-70-g09d2