mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Tz update (#7234)
* TZ update Added the possibility to set the timezone without using NTP. This is helpful to have the timezone advantages when using an external RTC. * Update time.cpp
This commit is contained in:
parent
ea1fdb210f
commit
b02643e7fa
@ -276,6 +276,8 @@ long secureRandom(long);
|
||||
long secureRandom(long, long);
|
||||
long map(long, long, long, long, long);
|
||||
|
||||
void setTZ(const char* tz);
|
||||
|
||||
void configTime(int timezone, int daylightOffset_sec, const char* server1,
|
||||
const char* server2 = nullptr, const char* server3 = nullptr);
|
||||
|
||||
|
@ -186,6 +186,14 @@ void configTime(int timezone_sec, int daylightOffset_sec, const char* server1, c
|
||||
/*** end of posix replacement ***/
|
||||
}
|
||||
|
||||
void setTZ(const char* tz){
|
||||
|
||||
char tzram[strlen_P(tz) + 1];
|
||||
memcpy_P(tzram, tz, sizeof(tzram));
|
||||
setenv("TZ", tzram, 1/*overwrite*/);
|
||||
tzset();
|
||||
}
|
||||
|
||||
void configTime(const char* tz, const char* server1, const char* server2, const char* server3)
|
||||
{
|
||||
sntp_stop();
|
||||
@ -193,10 +201,8 @@ void configTime(const char* tz, const char* server1, const char* server2, const
|
||||
setServer(0, server1);
|
||||
setServer(1, server2);
|
||||
setServer(2, server3);
|
||||
char tzram[strlen_P(tz) + 1];
|
||||
memcpy_P(tzram, tz, sizeof(tzram));
|
||||
setenv("TZ", tzram, 1/*overwrite*/);
|
||||
tzset();
|
||||
setTZ(tz);
|
||||
|
||||
sntp_init();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user