diff --git a/FamilyPlanner.ino b/FamilyPlanner.ino index dd79e6e..eb17fc3 100644 --- a/FamilyPlanner.ino +++ b/FamilyPlanner.ino @@ -59,7 +59,7 @@ const uint8_t *digits[10] = { image_data_icon_digit_0, image_data_icon_digit_1, char *ssid = "Freifunk"; char *pass = ""; char *calendarURL = "https://mail.unitas-network.de/mergedCalendars.json"; -int timeZone = 2; +char *timeZone = "CET-1CEST,M3.5.0/02,M10.5.0/03"; //Set to 1 to flip the screen 180 degrees #define ROTATION 3 @@ -98,9 +98,8 @@ void setup() { display.load1b(); //Update data -// if (timeDigits[0]+timeDigits[1]+timeDigits[2]+timeDigits[3] == 0) { if ((timeDigits[1] == 5) && (timeDigits[0] == 9)) { - network.begin(); // every midnight set the time from internet + network.begin(); // every hour set the time from internet network.off(); networking = true; } diff --git a/Network.cpp b/Network.cpp index 9446792..3e432df 100644 --- a/Network.cpp +++ b/Network.cpp @@ -34,15 +34,13 @@ void Network::begin() // Gets time from ntp server void Network::getTime(int *timeDigits) { - // Get seconds since 1.1.1970. - time_t nowSecs = time(nullptr); - - // Used to store time struct tm timeinfo; - gmtime_r(&nowSecs, &timeinfo); - // Setting time string timezone (Better defined modulo, in case timezone makes hours to go below 0) - timeinfo.tm_hour = ((timeinfo.tm_hour + timeZone) % 24 + 24) %24; + setenv("TZ", timeZone, 1); + tzset(); + + time_t nowSecs = time(nullptr); + localtime_r(&nowSecs, &timeinfo); // fill in the digits timeDigits[0] = timeinfo.tm_min % 10; //minutes (units) diff --git a/Network.h b/Network.h index 000e24f..b3c907f 100644 --- a/Network.h +++ b/Network.h @@ -4,7 +4,7 @@ #include // To get vars from main file -extern int timeZone; +extern char *timeZone; extern char calName[5][31]; extern char calStart[5][26]; extern char calTitle[5][81];