union int_or_float val;
switch (integer_or_float(buffer, &val)) {
- /* Integer values are probably in feet */
+ /* All values are probably in meters */
case INTEGER:
- depth->mm = 304.8 * val.i;
- break;
- /* Float? Probably meters.. */
+ val.fp = val.i;
+ /* fallthrough */
case FLOAT:
depth->mm = val.fp * 1000;
break;
len = snprintf(buffer, sizeof(buffer),
"%04d-%02d-%02d "
"%02d:%02d:%02d "
- "(%d ft, %d min)\n",
+ "(%d ft, %d min)",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec,
to_feet(dive->maxdepth), dive->duration.seconds / 60);
static void sample_end(void)
{
- sample = NULL;
if (!dive)
return;
+
+ if (sample->time.seconds > dive->duration.seconds) {
+ if (sample->depth.mm)
+ dive->duration = sample->time;
+ }
+
+ if (sample->depth.mm > dive->maxdepth.mm)
+ dive->maxdepth.mm = sample->depth.mm;
+
+ sample = NULL;
dive->samples++;
}