Skip to content

Commit a928025

Browse files
committed
Merge pull request #995 from Juppit/master
Updates for time.c
2 parents 810ab68 + a394787 commit a928025

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

cores/esp8266/Arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ long random(long, long);
271271
void randomSeed(unsigned long);
272272
long map(long, long, long, long, long);
273273

274-
extern "C" void configTime(int timezone, int daylightOffset_sec,
274+
extern "C" void configTime(long timezone, int daylightOffset_sec,
275275
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);
276276

277277
#endif

cores/esp8266/time.c

+3-4
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)