From 7ad43e1e40ee03916db0c096b0e20ef815e9102e Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Sat, 8 Jun 2024 17:03:33 +0300 Subject: [PATCH] Timezone fix (calculation one-liner) --- source/bforce/u_time.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/bforce/u_time.c b/source/bforce/u_time.c index a4a578c..84aa948 100644 --- a/source/bforce/u_time.c +++ b/source/bforce/u_time.c @@ -173,18 +173,20 @@ long time_gmtoffset(void) time_t tt = time(NULL); struct tm local = *localtime(&tt); struct tm gmt = *gmtime(&tt); - long tz = local.tm_yday - gmt.tm_yday; + long tz = 0; /* = local.tm_yday - gmt.tm_yday; if( tz > 1 ) tz = -24; else if( tz < -1 ) tz = +24; else - tz *= 24; + tz *= 24; */ - tz += gmt.tm_hour - local.tm_hour; + /*tz += gmt.tm_hour - local.tm_hour; tz *= 60; - tz += gmt.tm_min - local.tm_min; + tz += gmt.tm_min - local.tm_min;*/ + + tz = (gmt.tm_hour*60+gmt.tm_min) - (local.tm_hour*60+local.tm_min); return tz; }