mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
441e06cdb8
commit
8426024b76
1 changed files with 10 additions and 5 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue