1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-05-05 07:24:48 +03:00

Update time.cpp ()

* Update time.cpp

Migrate configTime() to use sntp_set_timezone_in_seconds() to correctly allow timezone spec in seconds without rounding

* Add sntp-lwip2.h for timezone function
This commit is contained in:
Develo 2019-05-03 16:56:49 -04:00 committed by david gauchard
parent a67aa569da
commit 3dbac1cab4
3 changed files with 16 additions and 4 deletions

@ -433,9 +433,8 @@ bool sntp_set_timezone_in_seconds(sint32 timezone)
if(timezone >= (-11 * (60 * 60)) || timezone <= (13 * (60 * 60))) {
time_zone = timezone;
return true;
} else {
return false;
}
return false;
}
/* Sets the timezone in hours. Internally, the timezone is converted to seconds. */

@ -0,0 +1,10 @@
#ifndef __sntp_lwip2_h__
#define __sntp_lwip2_h__
extern "C" {
bool sntp_set_timezone_in_seconds(sint32 timezone);
}
#endif

@ -22,6 +22,8 @@
#include "sntp.h"
#include "coredecls.h"
#include "sntp-lwip2.h"
extern "C" {
#ifndef _TIMEVAL_DEFINED
@ -58,7 +60,8 @@ static void setServer(int id, const char* name_or_ip)
}
}
void configTime(int timezone, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)
void configTime(int timezone_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)
{
sntp_stop();
@ -66,7 +69,7 @@ void configTime(int timezone, int daylightOffset_sec, const char* server1, const
setServer(1, server2);
setServer(2, server3);
sntp_set_timezone(timezone/3600);
sntp_set_timezone_in_seconds(timezone_sec);
sntp_set_daylight(daylightOffset_sec);
sntp_init();
}