[PATCH v2 3/7] nftables: meta: time: Proper handling of DST

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Ander Juaristi <a@xxxxxxxxxxxx>
---
 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




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux