NTP Timezone & Enable/Disable Setting (#80)

* quick and dirty WIP to investigate timezones, currently only building under esp8266 platform
much of the status stuff has been stripped for now, to test the concepts

* support set of common features across ESP32/ESP8266 WRT timezone and sntp
return dates as ISO format strings

* remove time library, and timelib fix which is no longer required

* fix the icons

* remove temporary changes to demo project
This commit is contained in:
rjwats
2020-01-20 11:14:46 +00:00
committed by GitHub
parent 59326c6426
commit ced5b74ba1
16 changed files with 620 additions and 184 deletions

View File

@@ -1,31 +1,27 @@
import * as Highlight from '../constants/Highlight';
export const NTP_TIME_NOT_SET = 0;
export const NTP_TIME_NEEDS_SYNC = 1;
export const NTP_TIME_SET = 2;
export const NTP_INACTIVE = 0;
export const NTP_ACTIVE = 1;
export const isSynchronized = ntpStatus => ntpStatus && (ntpStatus.status === NTP_TIME_NEEDS_SYNC || ntpStatus.status === NTP_TIME_SET);
export const isNtpActive = ntpStatus => ntpStatus && ntpStatus.status === NTP_ACTIVE;
export const ntpStatusHighlight = ntpStatus => {
switch (ntpStatus.status){
case NTP_TIME_SET:
switch (ntpStatus.status) {
case NTP_INACTIVE:
return Highlight.IDLE;
case NTP_ACTIVE:
return Highlight.SUCCESS;
case NTP_TIME_NEEDS_SYNC:
return Highlight.WARN;
case NTP_TIME_NOT_SET:
default:
return Highlight.ERROR;
}
}
export const ntpStatus = ntpStatus => {
switch (ntpStatus.status){
case NTP_TIME_SET:
return "Synchronized";
case NTP_TIME_NEEDS_SYNC:
return "Synchronization required";
case NTP_TIME_NOT_SET:
return "Time not set"
switch (ntpStatus.status) {
case NTP_INACTIVE:
return "Inactive";
case NTP_ACTIVE:
return "Active";
default:
return "Unknown";
}