parsing the date header honors the timezone offset

This commit is contained in:
SJ 2013-11-27 16:28:50 +01:00
parent c02766a18c
commit e133a41570
2 changed files with 17 additions and 2 deletions

View File

@ -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"

View File

@ -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, &lt);
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