mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
downloader: Simplify HTTPDate's timezone-correction code
This commit is contained in:
parent
ae33d62978
commit
23f779e799
@ -209,33 +209,13 @@ HTTPDate(const string &format) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything checks out; convert the date. rdb made this an if 0 check as
|
// Everything checks out; convert the date.
|
||||||
// timegm is a nonstandard extension so it fails in some situations even if
|
|
||||||
// the compiler defines __GNUC__
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
_time = timegm(&t);
|
|
||||||
|
|
||||||
#else // __GNUC__
|
|
||||||
// Without the GNU extension timegm, we have to use mktime() instead.
|
|
||||||
_time = mktime(&t);
|
_time = mktime(&t);
|
||||||
|
|
||||||
if (_time != (time_t)-1) {
|
if (_time != (time_t)-1) {
|
||||||
// Unfortunately, mktime() assumes local time; convert this back to GMT.
|
// Unfortunately, mktime() assumes local time; convert this back to GMT.
|
||||||
#if defined(IS_FREEBSD)
|
_time += (mktime(localtime(&_time)) - mktime(gmtime(&_time)));
|
||||||
time_t now = time(nullptr);
|
|
||||||
struct tm *tp = localtime(&now);
|
|
||||||
_time -= tp->tm_gmtoff;
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
long int timezone;
|
|
||||||
_get_timezone(&timezone);
|
|
||||||
_time -= timezone;
|
|
||||||
#else
|
|
||||||
extern long int timezone;
|
|
||||||
_time -= timezone;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif // __GNUC__
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user