From 66c264686d541f755558cb1e675f378169f9f99b Mon Sep 17 00:00:00 2001 From: tguenneguez <91618382+tguenneguez@users.noreply.github.com> Date: Thu, 10 Feb 2022 15:06:12 +0100 Subject: [PATCH] Add support use system TimeZone As explain in the issue : https://github.com/fluent/fluent-bit/issues/593 Defined parameter : Time_Offset to "System" This will use the system local timestamp. Very usefull when the timezone depending on Summer/Winter --- src/flb_parser.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/flb_parser.c b/src/flb_parser.c index faf5c4a89dd..d0bb5cf7ef7 100644 --- a/src/flb_parser.c +++ b/src/flb_parser.c @@ -40,6 +40,7 @@ #include #include #include +#include static inline uint32_t digits10(uint64_t v) { if (v < 10) return 1; @@ -934,6 +935,8 @@ int flb_parser_tzone_offset(const char *str, int len, int *tmdiff) long min; const char *end; const char *p = str; + time_t t = time(NULL); + struct tm lt = {0}; /* Check timezones */ if (*p == 'Z') { @@ -942,6 +945,15 @@ int flb_parser_tzone_offset(const char *str, int len, int *tmdiff) return 0; } + /* Check timezones */ + if (*p == 'System') { + /* This is UTC, no changes required */ + + localtime_r(&t, <); + *tmdiff = lt.tm_gmtoff; + return 0; + } + /* Unexpected timezone string */ if (*p != '+' && *p != '-') { *tmdiff = 0;