From 1c363f89cf5c9b427ad55b4d0d4167bdb176b8e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C5=93ur?= Date: Sun, 10 Nov 2024 20:21:49 +0100 Subject: [PATCH] fix incorrect dos date conversion --- mz_zip.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mz_zip.c b/mz_zip.c index 139a874b..f232d2e8 100644 --- a/mz_zip.c +++ b/mz_zip.c @@ -2662,12 +2662,12 @@ static int32_t mz_zip_invalid_date(const struct tm *ptm) { static void mz_zip_dosdate_to_raw_tm(uint64_t dos_date, struct tm *ptm) { uint64_t date = (uint64_t)(dos_date >> 16); - ptm->tm_mday = (uint16_t)(date & 0x1f); - ptm->tm_mon = (uint16_t)(((date & 0x1E0) / 0x20) - 1); - ptm->tm_year = (uint16_t)(((date & 0x0FE00) / 0x0200) + 80); - ptm->tm_hour = (uint16_t)((dos_date & 0xF800) / 0x800); - ptm->tm_min = (uint16_t)((dos_date & 0x7E0) / 0x20); - ptm->tm_sec = (uint16_t)(2 * (dos_date & 0x1f)); + ptm->tm_mday = (int16_t)(date & 0x1f); + ptm->tm_mon = (int16_t)(((date & 0x1E0) / 0x20) - 1); + ptm->tm_year = (int16_t)(((date & 0x0FE00) / 0x0200) + 80); + ptm->tm_hour = (int16_t)((dos_date & 0xF800) / 0x800); + ptm->tm_min = (int16_t)((dos_date & 0x7E0) / 0x20); + ptm->tm_sec = (int16_t)(2 * (dos_date & 0x1f)); ptm->tm_isdst = -1; }