working timezone config
This commit is contained in:
parent
b30cfde0b0
commit
b62ef700ed
|
@ -183,14 +183,14 @@ bool ESPMegaPRO::updateTimeFromNTP()
|
|||
return true;
|
||||
}
|
||||
|
||||
#include <sstream>
|
||||
|
||||
void ESPMegaPRO::setUTCOffset(int offset)
|
||||
/**
|
||||
* @brief Sets the timezone for the internal RTC.
|
||||
*
|
||||
* @note This function takes POSIX timezone strings (e.g. "EST5EDT,M3.2.0,M11.1.0").
|
||||
*/
|
||||
void ESPMegaPRO::setTimezone(const char* offset)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "UTC" << (offset >= 0 ? "+" : "") << offset;
|
||||
setenv("TZ", oss.str().c_str(), 1);
|
||||
tzset();
|
||||
setenv("TZ", offset, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,7 +52,7 @@ class ESPMegaPRO {
|
|||
void enableIotModule();
|
||||
void enableInternalDisplay(HardwareSerial *serial);
|
||||
void enableWebServer(uint16_t port);
|
||||
void setUTCOffset(int offset);
|
||||
void setTimezone(const char* offset);
|
||||
rtctime_t getTime();
|
||||
void dumpFRAMtoSerial(uint16_t start, uint16_t end);
|
||||
void dumpFRAMtoSerialASCII(uint16_t start, uint16_t end);
|
||||
|
|
|
@ -163,7 +163,7 @@ void setup()
|
|||
{
|
||||
ESP_LOGI("Initializer", "Starting ESPMegaPRO OOP demo");
|
||||
espmega.begin();
|
||||
espmega.setUTCOffset(7);
|
||||
espmega.setTimezone("UTC-7");
|
||||
ESP_LOGI("Initializer", "Enabling IOT module");
|
||||
espmega.enableIotModule();
|
||||
ESP_LOGI("Initializer", "Enabling Ethernet");
|
||||
|
|
Loading…
Reference in New Issue