Comments und add licence
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
RTC_PCF8523 rtc;
|
||||
|
||||
// Globale Zeitvariablen
|
||||
@@ -17,12 +16,14 @@ struct timezone tz;
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
|
||||
// Prototypen für Zeit-Management-Funktionen
|
||||
// Initialisiert die Zeit-API und richtet die HTTP-Endpunkte ein.
|
||||
void setupTimeAPI(AsyncWebServer &server);
|
||||
// Gibt die aktuelle Zeit als JSON-String zurück.
|
||||
String getCurrentTimeJSON();
|
||||
// Setzt die Systemzeit auf den angegebenen Zeitstempel (Sekunden seit 1970).
|
||||
bool setSystemTime(long timestamp);
|
||||
|
||||
// Hilfsfunktionen für Zeit-Management
|
||||
// Hilfsfunktion: Gibt die aktuelle Zeit als JSON-String zurück.
|
||||
String getCurrentTimeJSON() {
|
||||
gettimeofday(&tv, &tz);
|
||||
now = tv.tv_sec;
|
||||
@@ -48,6 +49,7 @@ String getCurrentTimeJSON() {
|
||||
return response;
|
||||
}
|
||||
|
||||
// Hilfsfunktion: Setzt die Systemzeit auf den angegebenen Zeitstempel.
|
||||
bool setSystemTime(long timestamp) {
|
||||
struct timeval tv;
|
||||
tv.tv_sec = timestamp;
|
||||
@@ -62,6 +64,7 @@ bool setSystemTime(long timestamp) {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialisiert die Zeit-API und richtet die HTTP-Endpunkte ein.
|
||||
void setupTimeAPI(AsyncWebServer &server) {
|
||||
|
||||
// setupRTC();
|
||||
@@ -185,6 +188,7 @@ void setupTimeAPI(AsyncWebServer &server) {
|
||||
}
|
||||
|
||||
// Hilfsfunktion: Zeit-Validierung
|
||||
// Prüft, ob die übergebenen Datums- und Zeitwerte gültig sind.
|
||||
bool isValidDateTime(int year, int month, int day, int hour, int minute,
|
||||
int second) {
|
||||
if (year < 2020 || year > 2099)
|
||||
@@ -211,6 +215,7 @@ bool isValidDateTime(int year, int month, int day, int hour, int minute,
|
||||
return day <= daysInMonth[month - 1];
|
||||
}
|
||||
|
||||
// Gibt den aktuellen Zeitstempel in Millisekunden seit 1970 zurück.
|
||||
uint64_t getCurrentTimestampMs() {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
Reference in New Issue
Block a user