1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Declare s_timezone_sec as long

Some more small fixes:
removed ensureBootTimeIsSet() from function time()
call sntp_setservername() with server id
This commit is contained in:
Juppit 2015-11-09 16:39:10 +01:00
parent 810ab68ae5
commit d46ad79aa0

View File

@ -35,7 +35,7 @@ extern struct tm* sntp_localtime(const time_t *clock);
#define DIFF1900TO1970 2208988800UL #define DIFF1900TO1970 2208988800UL
static int s_daylightOffset_sec = 0; static int s_daylightOffset_sec = 0;
static int s_timezone_sec = 0; static long s_timezone_sec = 0;
static time_t s_bootTime = 0; static time_t s_bootTime = 0;
// calculate offset used in gettimeofday // calculate offset used in gettimeofday
@ -46,7 +46,7 @@ static void ensureBootTimeIsSet()
time_t now = sntp_get_current_timestamp(); time_t now = sntp_get_current_timestamp();
if (now) if (now)
{ {
s_bootTime = - millis() / 1000; s_bootTime = now - millis() / 1000;
} }
} }
} }
@ -56,7 +56,7 @@ static void setServer(int id, const char* name_or_ip)
if (name_or_ip) if (name_or_ip)
{ {
//TODO: check whether server is given by name or IP //TODO: check whether server is given by name or IP
sntp_setservername(0, (char*) name_or_ip); sntp_setservername(id, (char*) name_or_ip);
} }
} }
@ -92,7 +92,6 @@ time_t mktime(struct tm *t)
time_t time(time_t * t) time_t time(time_t * t)
{ {
time_t seconds = sntp_get_current_timestamp(); time_t seconds = sntp_get_current_timestamp();
ensureBootTimeIsSet();
if (t) if (t)
{ {
*t = seconds; *t = seconds;