summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-09-20 11:41:44 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-09-20 11:41:44 -0700
commit574d4d4facb83ee5505a988f5dc5830602fc8048 (patch)
tree066da5a9aed77f145f5c942d2780df298a6a6b2d /save-xml.c
parentf4bc0ca37b47fd731bf55bc6c4675a34092771da (diff)
parent6d16a15196857eb4fe2eb4ca3cf363f1221afe60 (diff)
downloadsubsurface-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 'save-xml.c')
-rw-r--r--save-xml.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/save-xml.c b/save-xml.c
index 7ce0afbc1..55740ce92 100644
--- a/save-xml.c
+++ b/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);