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 /info.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 'info.c')
-rw-r--r-- | info.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -99,13 +99,15 @@ static char *get_combo_box_entry_text(GtkComboBoxEntry *combo_box, char **textp, static int divename(char *buf, size_t size, struct dive *dive) { - struct tm *tm = gmtime(&dive->when); + struct tm tm; + + utc_mkdate(dive->when, &tm); return snprintf(buf, size, "Dive #%d - %s %02d/%02d/%04d at %d:%02d", dive->number, - weekday(tm->tm_wday), - tm->tm_mon+1, tm->tm_mday, - tm->tm_year+1900, - tm->tm_hour, tm->tm_min); + weekday(tm.tm_wday), + tm.tm_mon+1, tm.tm_mday, + tm.tm_year+1900, + tm.tm_hour, tm.tm_min); } void show_dive_info(struct dive *dive) @@ -681,7 +683,7 @@ static GtkWidget *frame_box(GtkWidget *vbox, const char *fmt, ...) } /* Fixme - should do at least depths too - a dive without a depth is kind of pointless */ -static time_t dive_time_widget(struct dive *dive) +static timestamp_t dive_time_widget(struct dive *dive) { GtkWidget *dialog; GtkWidget *cal, *hbox, *vbox, *box; @@ -719,10 +721,11 @@ static time_t dive_time_widget(struct dive *dive) * we'll just take the current time. */ if (amount_selected == 1) { - time_t when = current_dive->when; + timestamp_t when = current_dive->when; when += current_dive->duration.seconds; when += 60*60; - time = gmtime(&when); + utc_mkdate(when, &tm); + time = &tm; } else { time_t now; struct timeval tv; |