improve code

pull/1/head
Thomas Ballmann 4 years ago
parent 6a1c6f8bba
commit 3e7c7223e1

@ -10,7 +10,6 @@ const char *ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 3600; const long gmtOffset_sec = 3600;
const int daylightOffset_sec = 3600; const int daylightOffset_sec = 3600;
int getNumberOfDays(int month, int year) int getNumberOfDays(int month, int year)
{ {
// leap year condition, if month is 2 // leap year condition, if month is 2
@ -28,7 +27,7 @@ int getNumberOfDays(int month, int year)
return 30; return 30;
} }
bool setupDateTime() bool updateDateTime()
{ {
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
if (!getLocalTime(&now)) if (!getLocalTime(&now))
@ -51,3 +50,18 @@ bool setupDateTime()
return true; return true;
} }
void setupDateTime()
{
if (!updateDateTime())
{
// re-try
updateDateTime();
}
}
void loopDateTime()
{
// TODO update...
//setupDateTime();
}
Loading…
Cancel
Save