Final? fix to timezone detection
This commit is contained in:
parent
c812344f52
commit
de13de9e4d
@ -67,16 +67,12 @@ const char* gmonths[] = {
|
|||||||
|
|
||||||
int tzoffset() {
|
int tzoffset() {
|
||||||
|
|
||||||
time_t t = time(NULL);
|
time_t t1 = time(NULL);
|
||||||
struct tm *a = localtime(&t);
|
struct tm *tp = gmtime(&t1);
|
||||||
int tz = a->tm_hour * 100 + a->tm_min;
|
tp->tm_isdst=-1;
|
||||||
a = gmtime(&t);
|
time_t t2 = mktime(tp);
|
||||||
tz -= a->tm_hour * 100 + a->tm_min;
|
int dt = (int)(t1 - t2);
|
||||||
if(tz < -24*100)
|
return (dt / 3600) * 100 + (dt % 3600) / 60;
|
||||||
tz += 24*100;
|
|
||||||
else if(tz > 24*100)
|
|
||||||
tz -= 24*100;
|
|
||||||
return tz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user