Skip to content

Commit d46ad79

Browse files
committed
Declare s_timezone_sec as long
Some more small fixes: removed ensureBootTimeIsSet() from function time() call sntp_setservername() with server id
1 parent 810ab68 commit d46ad79

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cores/esp8266/time.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern struct tm* sntp_localtime(const time_t *clock);
3535
#define DIFF1900TO1970 2208988800UL
3636

3737
static int s_daylightOffset_sec = 0;
38-
static int s_timezone_sec = 0;
38+
static long s_timezone_sec = 0;
3939
static time_t s_bootTime = 0;
4040

4141
// calculate offset used in gettimeofday
@@ -46,7 +46,7 @@ static void ensureBootTimeIsSet()
4646
time_t now = sntp_get_current_timestamp();
4747
if (now)
4848
{
49-
s_bootTime = - millis() / 1000;
49+
s_bootTime = now - millis() / 1000;
5050
}
5151
}
5252
}
@@ -56,7 +56,7 @@ static void setServer(int id, const char* name_or_ip)
5656
if (name_or_ip)
5757
{
5858
//TODO: check whether server is given by name or IP
59-
sntp_setservername(0, (char*) name_or_ip);
59+
sntp_setservername(id, (char*) name_or_ip);
6060
}
6161
}
6262

@@ -92,7 +92,6 @@ time_t mktime(struct tm *t)
9292
time_t time(time_t * t)
9393
{
9494
time_t seconds = sntp_get_current_timestamp();
95-
ensureBootTimeIsSet();
9695
if (t)
9796
{
9897
*t = seconds;

0 commit comments

Comments
 (0)