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
16
save-xml.c
16
save-xml.c
|
@ -284,13 +284,15 @@ static void save_events(FILE *f, struct event *ev)
|
|||
|
||||
static void save_trip(FILE *f, struct dive *trip)
|
||||
{
|
||||
struct tm *tm = gmtime(&trip->when);
|
||||
struct tm tm;
|
||||
|
||||
utc_mkdate(trip->when, &tm);
|
||||
|
||||
fprintf(f, "<trip");
|
||||
fprintf(f, " date='%04u-%02u-%02u'",
|
||||
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
|
||||
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday);
|
||||
fprintf(f, " time='%02u:%02u:%02u'",
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
if (trip->location)
|
||||
show_utf8(f, trip->location, " location=\'","\'", 1);
|
||||
fprintf(f, " />\n");
|
||||
|
@ -299,7 +301,9 @@ static void save_trip(FILE *f, struct dive *trip)
|
|||
static void save_dive(FILE *f, struct dive *dive)
|
||||
{
|
||||
int i;
|
||||
struct tm *tm = gmtime(&dive->when);
|
||||
struct tm tm;
|
||||
|
||||
utc_mkdate(dive->when, &tm);
|
||||
|
||||
fputs("<dive", f);
|
||||
if (dive->number)
|
||||
|
@ -309,9 +313,9 @@ static void save_dive(FILE *f, struct dive *dive)
|
|||
if (dive->rating)
|
||||
fprintf(f, " rating='%d'", dive->rating);
|
||||
fprintf(f, " date='%04u-%02u-%02u'",
|
||||
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
|
||||
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday);
|
||||
fprintf(f, " time='%02u:%02u:%02u'",
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
fprintf(f, " duration='%u:%02u min'>\n",
|
||||
FRACTION(dive->duration.seconds, 60));
|
||||
save_overview(f, dive);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue