memcpy (&tmp_tm, &tm, sizeof (tmp_tm));
errno = 0;
- const time_t t = mktime (&tmp_tm);
+
+ time_t t = mktime (&tmp_tm);
if (t == - 1) { /* Glibc does not set errno on out-of-range here! */
const char *datestr = asctime (&tm);
throw conversion_error (errno,
+ "}");
}
+ /*
+ * The timezone shenanigans are there to force we end up using UTC
+ * internally. The trouble with mktime(3) is that the unix timestamp
+ * is defined as “seconds since epoch” but “expressed as local time”.
+ */
+ t += tm.tm_gmtoff;
+ t -= timezone;
+
tmp_time = Time (t, 0l, id, var);
this->swap (tmp_time);