MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / updateTZ

Function updateTZ

xs/platforms/esp/xsHost.c:730–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

728
729#if ESP32
730static void updateTZ(void)
731{
732 int32_t offset = gTimeZoneOffset + gDaylightSavings;
733 int32_t hours, minutes;
734 char zone[10];
735
736 zone[0] = 'U';
737 zone[1] = 'T';
738 zone[2] = 'C';
739 zone[3] = (offset >= 0) ? '-' : '+'; // yes, backwards
740
741 if (offset < 0)
742 offset = -offset;
743 offset /= 60; // seconds to minutes
744 hours = offset / 60;
745 minutes = offset % 60;
746
747 zone[4] = (hours / 10) + '0';
748 zone[5] = (hours % 10) + '0';
749 zone[6] = ':';
750 zone[7] = (minutes / 10) + '0';
751 zone[8] = (minutes % 10) + '0';
752 zone[9] = 0;
753
754 setenv("TZ", zone, 1);
755 tzset();
756}
757#else
758 #define updateTZ()
759#endif

Callers 2

modSetTimeZoneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected