diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2011-05-23 17:42:37 +0200 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2011-05-25 01:02:41 +0200 |
commit | b1319cc083de658c0007da93f25d19874f75d55f (patch) | |
tree | 6250ecc2971650e7b8a3e153ecc4755dced7931c /extensions/libxt_time.c | |
parent | d8784613a5be2821ff910cd4c2bfe889a9b306c5 (diff) |
libxt_time: always ignore libc timezone
Since xt_time is meant to work across many months, libc doing
automatic conversion from local time to UTC (during parse) is
unwanted, especially when --utc is specified. The same goes for
dumping.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'extensions/libxt_time.c')
-rw-r--r-- | extensions/libxt_time.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/extensions/libxt_time.c b/extensions/libxt_time.c index b538476c..67b7f45d 100644 --- a/extensions/libxt_time.c +++ b/extensions/libxt_time.c @@ -136,6 +136,12 @@ static time_t time_parse_date(const char *s, bool end) tm.tm_min = minute; tm.tm_sec = second; tm.tm_isdst = 0; + /* + * Offsetting, if any, is done by xt_time.ko, + * so we have to disable it here in userspace. + */ + setenv("TZ", "UTC", true); + tzset(); ret = mktime(&tm); if (ret >= 0) return ret; @@ -289,7 +295,7 @@ static void time_print_date(time_t date, const char *command) if (date == 0 || date == LONG_MAX) return; - t = localtime(&date); + t = gmtime(&date); if (command != NULL) /* * Need a contiguous string (no whitespaces), hence using |