Skip to content

Commit

Permalink
fix show ntp_time (as local time)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Dec 23, 2024
1 parent 97925c4 commit 4c69c9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion interface/src/app/status/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { AuthenticatedContext } from 'contexts/authentication';
import { useI18nContext } from 'i18n/i18n-react';
import { NTPSyncStatus, NetworkConnectionStatus } from 'types';
import { useInterval } from 'utils';
import { formatDateTime } from 'utils/time';

import RestartMonitor from './RestartMonitor';

Expand Down Expand Up @@ -138,7 +139,7 @@ const SystemStatus = () => {
case NTPSyncStatus.NTP_INACTIVE:
return LL.INACTIVE(0);
case NTPSyncStatus.NTP_ACTIVE:
return LL.ACTIVE();
return LL.ACTIVE() + (data.ntp_time !== undefined) ? ' (' + formatDateTime(data.ntp_time) + ')' : '';
default:
return LL.UNKNOWN();
}
Expand Down
6 changes: 6 additions & 0 deletions src/web/WebStatusService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
}
return 0;
}();
time_t now = time(nullptr);
if (now > 1500000000L) {
char t[25];
strftime(t, sizeof(t), "%FT%T", localtime(&now));
root["ntp_time"] = t;
}
#endif

root["ap_status"] = EMSESP::esp8266React.apStatus();
Expand Down

0 comments on commit 4c69c9e

Please sign in to comment.