aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_task.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-21 14:18:42 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-21 14:18:42 +0000
commit81e8e5e413ad8ba9dfb8b8f7da5ab2939dac4534 (patch)
treea14b6ebb14c83f03c8dd056b7be4a4843cd56b51 /src/lua/lua_task.c
parentd73a3db2211150ec12bd3c91e7e78b74b6ad19a0 (diff)
downloadrspamd-81e8e5e413ad8ba9dfb8b8f7da5ab2939dac4534.tar.gz
rspamd-81e8e5e413ad8ba9dfb8b8f7da5ab2939dac4534.zip
[Feature] Use own code for parsing of date
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r--src/lua/lua_task.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 68d9b9704..96c03847c 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -26,6 +26,7 @@
#include "utlist.h"
#include "cryptobox.h"
#include "unix-std.h"
+#include "libmime/smtp_parsers.h"
/***
* @module rspamd_task
@@ -2591,16 +2592,23 @@ lua_task_get_date (lua_State *L)
if (hdrs && hdrs->len > 0) {
time_t tt;
- gint offset;
+ struct tm t;
struct rspamd_mime_header *h;
h = g_ptr_array_index (hdrs, 0);
- tt = g_mime_utils_header_decode_date (h->decoded, &offset);
+ tt = rspamd_parse_smtp_date (h->raw_value, h->raw_len);
if (!gmt) {
- tt += (offset * 60 * 60) / 100 + (offset * 60 * 60) % 100;
+ localtime_r (&tt, &t);
+#if !defined(__sun)
+ t.tm_gmtoff = 0;
+#endif
+ t.tm_isdst = 0;
+ tim = mktime (&t);
+ }
+ else {
+ tim = tt;
}
- tim = tt;
}
else {
tim = 0.0;