mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 08:10:12 +01:00
parsing the date header honors the timezone offset
This commit is contained in:
parent
c02766a18c
commit
e133a41570
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define VERSION "0.1.25-master-branch"
|
#define VERSION "0.1.25-master-branch"
|
||||||
|
|
||||||
#define BUILD 853
|
#define BUILD 854
|
||||||
|
|
||||||
#define HOSTID "mailarchiver"
|
#define HOSTID "mailarchiver"
|
||||||
|
|
||||||
|
@ -102,10 +102,19 @@ void init_state(struct _state *state){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long get_local_timezone_offset(){
|
||||||
|
time_t t = time(NULL);
|
||||||
|
struct tm lt = {0};
|
||||||
|
localtime_r(&t, <);
|
||||||
|
return lt.tm_gmtoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned long parse_date_header(char *datestr, struct __config *cfg){
|
unsigned long parse_date_header(char *datestr, struct __config *cfg){
|
||||||
int n=0;
|
int n=0;
|
||||||
char *p, *q, *r, s[SMALLBUFSIZE];
|
long offset=0;
|
||||||
unsigned long ts=0;
|
unsigned long ts=0;
|
||||||
|
char *p, *q, *r, s[SMALLBUFSIZE];
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
datestr += 5;
|
datestr += 5;
|
||||||
@ -175,6 +184,12 @@ unsigned long parse_date_header(char *datestr, struct __config *cfg){
|
|||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
ts = mktime(&tm);
|
ts = mktime(&tm);
|
||||||
|
|
||||||
|
if(p && (*p == '+' || *p == '-')){
|
||||||
|
offset = atoi(p) / 100 * 3600;
|
||||||
|
ts += get_local_timezone_offset() - offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_TWEAK_SENT_TIME
|
#ifdef HAVE_TWEAK_SENT_TIME
|
||||||
if(ts > 631148400) ts += cfg->tweak_sent_time_offset;
|
if(ts > 631148400) ts += cfg->tweak_sent_time_offset;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user