X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=statistics.c;h=f8f9d0e24549ca10c568eb85fcc2b957ea14a814;hb=549ad65bcb39e95c4deae0b77eb2476efa53df43;hp=80cab2b02b82c4096750db31ab77438b102ca02b;hpb=0e64a22c142bbb2415b010968194948c592b1542;p=ext%2Fsubsurface.git diff --git a/statistics.c b/statistics.c index 80cab2b..f8f9d0e 100644 --- a/statistics.c +++ b/statistics.c @@ -125,10 +125,18 @@ void show_dive_stats(struct dive *dive) const char *unit; int idx, offset, gas_used; struct dive *prev_dive; + struct tm *tm; process_all_dives(dive, &prev_dive); - strftime(buf, 80, "%a, %b %d, %Y, %k:%M", gmtime(&dive->when)); + tm = gmtime(&dive->when); + snprintf(buf, sizeof(buf), + "%s, %s %d, %d %2d:%02d", + weekday(tm->tm_wday), + monthname(tm->tm_mon), + tm->tm_mday, tm->tm_year + 1900, + tm->tm_hour, tm->tm_min); + set_label(info_stat_w.date, buf); set_label(info_stat_w.dive_time, "%d min", (dive->duration.seconds + 30) / 60); if (prev_dive) @@ -140,7 +148,7 @@ void show_dive_stats(struct dive *dive) set_label(info_stat_w.max_depth, "%.*f %s", decimals, value, unit); value = get_depth_units(dive->meandepth.mm, &decimals, &unit); set_label(info_stat_w.avg_depth, "%.*f %s", decimals, value, unit); - if (dive->watertemp.mkelvin > 200) { + if (dive->watertemp.mkelvin) { value = get_temp_units(dive->watertemp.mkelvin, &unit); set_label(info_stat_w.water_temp, "%.1f %s", value, unit); } else @@ -157,11 +165,11 @@ void show_dive_stats(struct dive *dive) /* for the O2/He readings just create a list of them */ for (idx = 0; idx < MAX_CYLINDERS; idx++) { cylinder_t *cyl = &dive->cylinder[idx]; - /* we assume that every valid cylinder has either a working pressure - * or a size; but for good measure let's also accept cylinders with - * a starting or ending pressure*/ - if (cyl->type.workingpressure.mbar || cyl->type.size.mliter || - cyl->start.mbar || cyl->end.mbar) { + unsigned int start, end; + + start = cyl->start.mbar ? : cyl->sample_start.mbar; + end = cyl->end.mbar ? : cyl->sample_end.mbar; + if (!cylinder_none(cyl)) { /* 0% O2 strangely means air, so 21% - I don't like that at all */ int o2 = cyl->gasmix.o2.permille ? : 209; if (offset > 0) { @@ -174,12 +182,10 @@ void show_dive_stats(struct dive *dive) } /* and if we have size, start and end pressure, we can * calculate the total gas used */ - if (cyl->type.size.mliter && cyl->start.mbar && cyl->end.mbar) - gas_used += cyl->type.size.mliter / 1000.0 * - (cyl->start.mbar - cyl->end.mbar); + if (cyl->type.size.mliter && start && end) + gas_used += cyl->type.size.mliter / 1000.0 * (start - end); } - if (offset) - set_label(info_stat_w.o2he, buf); + set_label(info_stat_w.o2he, buf); if (gas_used) { value = get_volume_units(gas_used, &decimals, &unit); set_label(info_stat_w.gas_used, "%.*f %s", decimals, value, unit);