diff --git a/RTC/read.py b/RTC/read.py index 4612223..417cb39 100644 --- a/RTC/read.py +++ b/RTC/read.py @@ -47,7 +47,7 @@ def main(): # Calculate time difference (in seconds) if RTC is connected if rtc_time: rtc_time_str = rtc_time.strftime('%Y-%m-%d %H:%M:%S') - time_difference = int((system_utc_time - rtc_time).total_seconds()) # Convert to int + time_difference = int((utc_time - rtc_time).total_seconds()) # Convert to int else: rtc_time_str = "not connected" time_difference = "N/A" # Not applicable diff --git a/html/admin.html b/html/admin.html index fbc8b78..47daafa 100755 --- a/html/admin.html +++ b/html/admin.html @@ -122,6 +122,10 @@ + +
+ + @@ -222,6 +226,30 @@ window.onload = function() { document.getElementById("sys_local_time").value = response.system_local_time; document.getElementById("sys_UTC_time").value = response.system_utc_time; document.getElementById("RTC_utc_time").value = response.rtc_module_time; + + // Get the time difference + const timeDiff = response.time_difference_seconds; + + // Reference to the alert container + const alertContainer = document.getElementById("alert_container"); + + // Remove any previous alert + alertContainer.innerHTML = ""; + + // Add an alert based on time difference + if (typeof timeDiff === "number") { + if (timeDiff >= 0 && timeDiff <= 10) { + alertContainer.innerHTML = ` + `; + } else if (timeDiff > 10) { + alertContainer.innerHTML = ` + `; + } + } }, error: function(xhr, status, error) { console.error('AJAX request failed:', status, error);