20 char currentTimezone[100];
21 char* envTimezone = getenv(
"TZ");
25 strcpy(currentTimezone, envTimezone);
29 setenv(
"TZ",
"UTC0", 1);
33 DS3231_init(DS3231_CONTROL_INTCN);
41 memset(&timeBuf, 0,
sizeof(tm));
42 timeBuf.tm_year = rtcTime.year - 1900;
43 timeBuf.tm_mon = rtcTime.mon - 1;
44 timeBuf.tm_mday = rtcTime.mday;
45 timeBuf.tm_hour = rtcTime.hour;
46 timeBuf.tm_min = rtcTime.min;
47 timeBuf.tm_sec = rtcTime.sec;
48 timeBuf.tm_isdst = -1;
52 tv.tv_sec = mktime(&timeBuf);
56 settimeofday(&tv, NULL);
60 setenv(
"TZ", currentTimezone, 1);
76 gmtime_r(&tNow, &timeBuf);
79 rtcTime.year = timeBuf.tm_year + 1900;
80 rtcTime.mon = timeBuf.tm_mon + 1;
81 rtcTime.mday = timeBuf.tm_mday;
82 rtcTime.hour = timeBuf.tm_hour;
83 rtcTime.min = timeBuf.tm_min;
84 rtcTime.sec = timeBuf.tm_sec;
87 DS3231_init(DS3231_CONTROL_INTCN);
Helper syncinc the SystemClock with the RTC running in UTC.
Definition: RealTimeClock.h:14
static void loadTimeFromRtc()
Sets the system clock based on the RTC.
Definition: RealTimeClock.h:19
static void saveTimeToRtc()
Sets the RTC time to the value of the system clock.
Definition: RealTimeClock.h:68