mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
update ntp lib to moment
This commit is contained in:
@@ -52,10 +52,9 @@ void NTPSettingsService::configureNTP() {
|
||||
|
||||
void NTPSettingsService::configureTime(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
if (!sntp_enabled() && json.is<JsonObject>()) {
|
||||
String timeUtc = json["time_utc"];
|
||||
struct tm tm = {0};
|
||||
|
||||
char * s = strptime(timeUtc.c_str(), "%Y-%m-%dT%H:%M:%SZ", &tm);
|
||||
struct tm tm = {0};
|
||||
String timeLocal = json["local_time"];
|
||||
char * s = strptime(timeLocal.c_str(), "%Y-%m-%dT%H:%M:%S", &tm);
|
||||
if (s != nullptr) {
|
||||
time_t time = mktime(&tm);
|
||||
struct timeval now = {.tv_sec = time};
|
||||
@@ -65,7 +64,6 @@ void NTPSettingsService::configureTime(AsyncWebServerRequest * request, JsonVari
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AsyncWebServerResponse * response = request->beginResponse(400);
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ void NTPStatus::ntpStatus(AsyncWebServerRequest * request) {
|
||||
// the current time in UTC
|
||||
root["utc_time"] = toUTCTimeString(gmtime(&now));
|
||||
|
||||
// local time as ISO String with TZ
|
||||
// local time with offset
|
||||
root["local_time"] = toLocalTimeString(localtime(&now));
|
||||
|
||||
// the sntp server name
|
||||
root["server"] = sntp_getservername(0);
|
||||
|
||||
// device uptime in seconds
|
||||
root["uptime"] = uuid::get_uptime() / 1000;
|
||||
root["uptime"] = millis() / 1000;
|
||||
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
|
||||
Reference in New Issue
Block a user