#ifdef ENABLE_FEATURE_NTP_TIME
bool setupTime()
{
    if (strlen(confTime.ntpServer1) > 4 && strlen(confTime.ntpServer2) > 4)
    {
        //configTime(gmtOffset_sec, daylightOffset_sec, ntpServer [, ntpServer2[, ntpServer3]]);
        configTime(0, 0, confTime.ntpServer1, confTime.ntpServer2);
    }
    else if (strlen(confTime.ntpServer1) > 4)
    {
        configTime(0, 0, confTime.ntpServer1);
    }
    else return false;
    setenv("TZ", confTime.timeZoneStr, 1); // Zeitzone einstellen https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv
    sendLog(F("NTP:  updating time..."), LOGLEVEL_INFO);
    return true;
}

void syncClock(bool force)
{
    time_t now = time(&now);
    static time_t lastsek{0};
    if (lt.tm_sec != lastsek || force)
    {
        lastsek = lt.tm_sec;
        if (force || !(time(&now) % confTime.ntpSyncInterval))
        {
            //sendLog(F("NTP:  updating time"), LOGLEVEL_INFO);
            setupTime();
        }
    }
}

void updateTime() {
    time_t now = time(&now);
    localtime_r(&now, &lt);
}

void printDate() {
    char buf[30];
    strftime(buf, sizeof(buf), "DATE: %Y-%m-%d %H:%M:%S", &lt);
    sendLog(buf);
}
#endif
