Fix the date/time with timezone offset

When using the dc_datetime_gmtime() function for a timestamp with a
timezone offset, the timezone offset needs to be added to the timestamp
prior to the call.
This commit is contained in:
Jef Driesen 2024-05-20 20:59:03 +02:00
parent eb4b082b1b
commit 72a88b18d9

View File

@ -709,13 +709,21 @@ divesoft_freedom_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *date
return status; return status;
unsigned int timestamp = array_uint32_le (data + 8); unsigned int timestamp = array_uint32_le (data + 8);
dc_ticks_t ticks = (dc_ticks_t) timestamp + EPOCH;
int timezone = 0;
if (parser->version == HEADER_SIGNATURE_V2) {
timezone = ((signed short) array_uint16_le (data + 40)) * 60;
} else {
timezone = 0;
}
dc_ticks_t ticks = (dc_ticks_t) timestamp + EPOCH + timezone;
if (!dc_datetime_gmtime (datetime, ticks)) if (!dc_datetime_gmtime (datetime, ticks))
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
if (parser->version == HEADER_SIGNATURE_V2) { if (parser->version == HEADER_SIGNATURE_V2) {
datetime->timezone = ((signed short) array_uint16_le (data + 40)) * 60; datetime->timezone = timezone;
} else { } else {
datetime->timezone = DC_TIMEZONE_NONE; datetime->timezone = DC_TIMEZONE_NONE;
} }