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