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>
This commit is contained in:
Linus Torvalds 2018-09-25 15:35:47 -07:00 committed by Dirk Hohndel
parent 441e06cdb8
commit 8426024b76

View file

@ -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);