From: Ander Juaristi <a@juaristi.eus>
To: netfilter-devel@vger.kernel.org
Cc: Ander Juaristi <a@juaristi.eus>
Subject: [PATCH v2 3/7] nftables: meta: time: Proper handling of DST
Date: Wed, 26 Jun 2019 22:43:58 +0200 [thread overview]
Message-ID: <20190626204402.5257-3-a@juaristi.eus> (raw)
In-Reply-To: <20190626204402.5257-1-a@juaristi.eus>
Signed-off-by: Ander Juaristi <a@juaristi.eus>
---
src/meta.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/meta.c b/src/meta.c
index 39e551c..bfe8aaa 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -408,6 +408,7 @@ static void date_type_print(const struct expr *expr, struct output_ctx *octx)
static time_t parse_iso_date(const char *sym)
{
time_t ts = time(NULL);
+ long int gmtoff;
struct tm tm, *cur_tm;
memset(&tm, 0, sizeof(struct tm));
@@ -433,7 +434,10 @@ success:
return ts;
/* Substract tm_gmtoff to get the current time */
- return ts - cur_tm->tm_gmtoff;
+ gmtoff = cur_tm->tm_gmtoff;
+ if (cur_tm->tm_isdst == 1)
+ gmtoff -= 3600;
+ return ts - gmtoff;
}
static struct error_record *date_type_parse(const struct expr *sym,
--
2.17.1
next prev parent reply other threads:[~2019-06-26 20:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 20:43 [PATCH v2 1/7] nftables: meta: Introduce new conditions 'time', 'day' and 'hour' Ander Juaristi
2019-06-26 20:43 ` [PATCH v2 2/7] nftables: meta: hour: Fix integer overflow error Ander Juaristi
2019-06-26 21:07 ` Florian Westphal
2019-06-26 20:43 ` Ander Juaristi [this message]
2019-06-26 21:07 ` [PATCH v2 3/7] nftables: meta: time: Proper handling of DST Florian Westphal
2019-06-27 19:10 ` Pablo Neira Ayuso
2019-06-26 20:43 ` [PATCH v2 4/7] nftables: tests/py: Add tests for day and hour Ander Juaristi
2019-06-26 21:06 ` Florian Westphal
2019-06-26 20:44 ` [PATCH v2 5/7] nftables: meta: Some small style fixes Ander Juaristi
2019-06-26 21:11 ` Florian Westphal
2019-06-26 20:44 ` [PATCH v2 6/7] nftables: Compute result modulo 86400 in case gmtoff is negative Ander Juaristi
2019-06-26 20:44 ` [PATCH v2 7/7] nftables: tests/py: More tests for day and hour Ander Juaristi
2019-06-26 21:12 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190626204402.5257-3-a@juaristi.eus \
--to=a@juaristi.eus \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).