From f856975f05ecb3ceb7f9baaa790645f3f84278f2 Mon Sep 17 00:00:00 2001 From: Jeremias Stotter Date: Sat, 10 Jan 2026 22:25:17 +0100 Subject: [PATCH] Look up the timezone when an entry is recorded and store it With big rec files, lookup might be incredibly slow because the timezone will be looked up for every entry. Like this, timezone is recorded once when an entry is created and doesn't have to be looked up later --- recorder.c | 15 ++++++++++++++- storage.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/recorder.c b/recorder.c index 4481c71..52c3967 100644 --- a/recorder.c +++ b/recorder.c @@ -55,7 +55,10 @@ #endif #include "version.h" #include - +#ifdef WITH_TZ +# include "zonedetect.h" +extern ZoneDetect *zdb; +#endif #define SSL_VERIFY_PEER (1) #define SSL_VERIFY_NONE (0) @@ -1056,6 +1059,16 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle } } +#ifdef WITH_TZ + if ((j = json_find_member(json, "tzname")) == NULL) { + char* tz_str = ZDHelperSimpleLookupString(zdb, lat, lon); + if (tz_str) { + json_append_member(json, "tzname", json_mkstring(tz_str)); + ZDHelperSimpleLookupStringFree(tz_str); + } + } +#endif + if ((j = json_find_member(json, "_geoprec")) != NULL) { if (j->tag == JSON_STRING) { geoprec = atoi(j->string_); diff --git a/storage.c b/storage.c index 087fe4b..27068de 100644 --- a/storage.c +++ b/storage.c @@ -46,7 +46,7 @@ static struct gcache *gc = NULL; #ifdef WITH_TZ # include "zonedetect.h" -static ZoneDetect *zdb = NULL; +ZoneDetect *zdb = NULL; #endif void storage_init(int revgeo)