diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-09-20 11:41:44 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-09-20 11:41:44 -0700 |
commit | 574d4d4facb83ee5505a988f5dc5830602fc8048 (patch) | |
tree | 066da5a9aed77f145f5c942d2780df298a6a6b2d /statistics.c | |
parent | f4bc0ca37b47fd731bf55bc6c4675a34092771da (diff) | |
parent | 6d16a15196857eb4fe2eb4ca3cf363f1221afe60 (diff) | |
download | subsurface-574d4d4facb83ee5505a988f5dc5830602fc8048.tar.gz |
Merge branch 'time-function'
Merge the 64-bit timestamp_t time function branch.
This makes subsurface not only safe against the 2038-year problem, but
also avoids the use of thread-unsafe gmtime() etc.
We still use the system time_t for initializing the calendar widget for
adding a new dive, but that's cosmetic rather than anything fundamental.
* time-function:
FIND_TRIP: don't cast a timestamp to a pointer
dive-time widget: fix incorrect use of timestamp_t
Fix the incorrect data type for DIVE_DATE accesses
Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'
Diffstat (limited to 'statistics.c')
-rw-r--r-- | statistics.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/statistics.c b/statistics.c index 5e1c8804a..35b9cecb9 100644 --- a/statistics.c +++ b/statistics.c @@ -364,7 +364,7 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) { int idx; struct dive *dp; - struct tm *tm; + struct tm tm; int current_year = 0; int current_month = 0; int year_iter = 0; @@ -408,12 +408,12 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) process_dive(dp, &stats); /* yearly statistics */ - tm = gmtime(&dp->when); + utc_mkdate(dp->when, &tm); if (current_year == 0) - current_year = tm->tm_year + 1900; + current_year = tm.tm_year + 1900; - if (current_year != tm->tm_year + 1900) { - current_year = tm->tm_year + 1900; + if (current_year != tm.tm_year) { + current_year = tm.tm_year + 1900; process_dive(dp, &(stats_yearly[++year_iter])); } else process_dive(dp, &(stats_yearly[year_iter])); @@ -423,10 +423,10 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) /* monthly statistics */ if (current_month == 0) { - current_month = tm->tm_mon + 1; + current_month = tm.tm_mon + 1; } else { - if (current_month != tm->tm_mon + 1) - current_month = tm->tm_mon + 1; + if (current_month != tm.tm_mon + 1) + current_month = tm.tm_mon + 1; if (prev_month != current_month || prev_year != current_year) month_iter++; } @@ -495,17 +495,17 @@ static void show_single_dive_stats(struct dive *dive) const char *unit; int idx, offset, gas_used; struct dive *prev_dive; - struct tm *tm; + struct tm tm; process_all_dives(dive, &prev_dive); - tm = gmtime(&dive->when); + utc_mkdate(dive->when, &tm); 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); + weekday(tm.tm_wday), + monthname(tm.tm_mon), + tm.tm_mday, tm.tm_year + 1900, + tm.tm_hour, tm.tm_min); set_label(single_w.date, buf); set_label(single_w.dive_time, "%d min", (dive->duration.seconds + 30) / 60); |