TZ magic in ESP/M5Unified
-
Mt RTC is set to UTC. Somehow, this magically works:
setenv("TZ","PST8PDT",1); tzset(); auto tm = localtime(&t); M5.Display.printf("ESP32 %04d/%02d/%02d (%s) %02d:%02d:%02d\r\n", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, wd[tm->tm_wday], tm->tm_hour, tm->tm_min, tm->tm_sec);
Just posting here in case someone is mystified by the Rtc.ino example, since it doesn't set the TZ "environmen variable" the calls to localtime and gmtime will return the same.