summaryrefslogtreecommitdiffstats
path: root/print.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-09-19 17:35:52 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-09-19 17:35:52 -0700
commitdce08deb34939eaed349d315777214c3181c1a8d (patch)
tree4c9695b79277edba4cbf1e75dbcc4bec026511b6 /print.c
parentd14932058f191de2a812a9b3b9ad87c5febd2b3e (diff)
downloadsubsurface-dce08deb34939eaed349d315777214c3181c1a8d.tar.gz
Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'
This makes the time type unambiguous, and we can use G_TYPE_INT64 for it in the divelist too. It also implements a portable (and thread-safe) "utc_mkdate()" function that acts kind of like gmtime_r(), but using the 64-bit timestamp_t. It matches our original "utc_mktime()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'print.c')
-rw-r--r--print.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/print.c b/print.c
index 12504b13d..5adba94cd 100644
--- a/print.c
+++ b/print.c
@@ -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);