aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2018-09-25 15:35:47 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-26 12:13:20 -0700
commit8426024b76ebc6e3aa3def24aa077a5b7442347c (patch)
treeec5b1e99f21f9ba17f6d28074ea25da853b128ac /core
parent441e06cdb89d8c3be39a6a99d092a2b30d67dd0a (diff)
downloadsubsurface-8426024b76ebc6e3aa3def24aa077a5b7442347c.tar.gz
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 <matthew.s.critchley@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core')
-rw-r--r--core/parse-xml.c15
1 files changed, 10 insertions, 5 deletions
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);