/* * SPDX-FileCopyrightText: 2023 Helmut Pozimski * * SPDX-License-Identifier: GPL-2.0-only */ #include #include #include #include "configuration.h" static SemaphoreHandle_t mutex = NULL; struct tm* convert_to_local(struct tm *timeinfo) { if (mutex == NULL) { mutex = xSemaphoreCreateMutex(); } xSemaphoreTake(mutex, portMAX_DELAY); setenv("TZ", "GMT+0GMT+0", 1); tzset(); time_t epoch_time = mktime(timeinfo); setenv("TZ", LOCAL_TIMEZONE, 1); tzset(); struct tm* result = localtime(&epoch_time); setenv("TZ", "GMT+0GMT+0", 1); tzset(); xSemaphoreGive(mutex); return result; }