diff options
author | 2012-09-20 11:41:44 -0700 | |
---|---|---|
committer | 2012-09-20 11:41:44 -0700 | |
commit | 574d4d4facb83ee5505a988f5dc5830602fc8048 (patch) | |
tree | 066da5a9aed77f145f5c942d2780df298a6a6b2d /print.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 'print.c')
-rw-r--r-- | print.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -51,7 +51,7 @@ static void show_dive_text(struct dive *dive, cairo_t *cr, double w, const char *unit; int len, decimals, width, height, maxwidth, maxheight; PangoLayout *layout; - struct tm *tm; + struct tm tm; char buffer[80], divenr[20], *people; maxwidth = w * PANGO_SCALE; @@ -65,14 +65,14 @@ static void show_dive_text(struct dive *dive, cairo_t *cr, double w, if (dive->number) snprintf(divenr, sizeof(divenr), "Dive #%d - ", dive->number); - tm = gmtime(&dive->when); + utc_mkdate(dive->when, &tm); len = snprintf(buffer, sizeof(buffer), "%s%s, %s %d, %d %d:%02d", divenr, - 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_font(layout, font, FONT_LARGE, PANGO_ALIGN_LEFT); pango_layout_set_text(layout, buffer, len); @@ -194,7 +194,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w, int len, decimals; double maxwidth, maxheight, colwidth, curwidth; PangoLayout *layout; - struct tm *tm; + struct tm tm; char buffer[160], divenr[20]; maxwidth = w * PANGO_SCALE; @@ -223,13 +223,13 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w, // Col 2: Date # pango_layout_set_width(layout, colwidth); - tm = gmtime(&dive->when); + utc_mkdate(dive->when, &tm); len = snprintf(buffer, sizeof(buffer), "%s, %s %d, %d %dh%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 ); cairo_move_to(cr, curwidth / PANGO_SCALE, 0); pango_layout_set_text(layout, buffer, len); |