make sure scan_httpdate uses GMT for mktime
This commit is contained in:
parent
7cd919d333
commit
265e2df10c
@ -1,7 +1,9 @@
|
|||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include "byte.h"
|
#include "byte.h"
|
||||||
#include "case.h"
|
#include "case.h"
|
||||||
|
#define _GNU_SOURCE
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static int parsetime(const char*c,struct tm* x) {
|
static int parsetime(const char*c,struct tm* x) {
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
@ -54,6 +56,15 @@ unsigned int scan_httpdate(const char *in,time_t *t) {
|
|||||||
if (byte_equal(c,3,"GMT")) c+=3;
|
if (byte_equal(c,3,"GMT")) c+=3;
|
||||||
done:
|
done:
|
||||||
x.tm_wday=x.tm_yday=x.tm_isdst=0;
|
x.tm_wday=x.tm_yday=x.tm_isdst=0;
|
||||||
|
#if defined(__dietlibc__) || defined(__GLIBC__)
|
||||||
|
*t=timegm(&x);
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
char* old=getenv("TZ");
|
||||||
|
unsetenv("TZ");
|
||||||
*t=mktime(&x);
|
*t=mktime(&x);
|
||||||
|
if (old) setenv("TZ",old,1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return c-in;
|
return c-in;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user