Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support use system TimeZone #4849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/flb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <sys/stat.h>
#include <limits.h>
#include <string.h>
#include <time.h>

static inline uint32_t digits10(uint64_t v) {
if (v < 10) return 1;
Expand Down Expand Up @@ -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') {
Expand All @@ -942,6 +945,15 @@ int flb_parser_tzone_offset(const char *str, int len, int *tmdiff)
return 0;
}

/* Check timezones */
if (*p == 'S') {
/* This is Timezone of the System */

localtime_r(&t, &lt);
*tmdiff = lt.tm_gmtoff;
return 0;
}

/* Unexpected timezone string */
if (*p != '+' && *p != '-') {
*tmdiff = 0;
Expand Down