Timezone fix (calculation one-liner)

master
Alexey Khromov 6 months ago
parent 0663d62be8
commit 7ad43e1e40

@ -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;
}

Loading…
Cancel
Save