mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
d14932058f
commit
dce08deb34
10 changed files with 195 additions and 114 deletions
24
print.c
24
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue