better time zone handling
This commit is contained in:
parent
dfdac04820
commit
334fecb472
|
@ -59,7 +59,7 @@ const uint8_t *digits[10] = { image_data_icon_digit_0, image_data_icon_digit_1,
|
||||||
char *ssid = "Freifunk";
|
char *ssid = "Freifunk";
|
||||||
char *pass = "";
|
char *pass = "";
|
||||||
char *calendarURL = "https://mail.unitas-network.de/mergedCalendars.json";
|
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
|
//Set to 1 to flip the screen 180 degrees
|
||||||
#define ROTATION 3
|
#define ROTATION 3
|
||||||
|
@ -98,9 +98,8 @@ void setup() {
|
||||||
display.load1b();
|
display.load1b();
|
||||||
|
|
||||||
//Update data
|
//Update data
|
||||||
// if (timeDigits[0]+timeDigits[1]+timeDigits[2]+timeDigits[3] == 0) {
|
|
||||||
if ((timeDigits[1] == 5) && (timeDigits[0] == 9)) {
|
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();
|
network.off();
|
||||||
networking = true;
|
networking = true;
|
||||||
}
|
}
|
||||||
|
|
12
Network.cpp
12
Network.cpp
|
@ -34,15 +34,13 @@ void Network::begin()
|
||||||
// Gets time from ntp server
|
// Gets time from ntp server
|
||||||
void Network::getTime(int *timeDigits)
|
void Network::getTime(int *timeDigits)
|
||||||
{
|
{
|
||||||
// Get seconds since 1.1.1970.
|
|
||||||
time_t nowSecs = time(nullptr);
|
|
||||||
|
|
||||||
// Used to store time
|
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
gmtime_r(&nowSecs, &timeinfo);
|
|
||||||
|
|
||||||
// Setting time string timezone (Better defined modulo, in case timezone makes hours to go below 0)
|
setenv("TZ", timeZone, 1);
|
||||||
timeinfo.tm_hour = ((timeinfo.tm_hour + timeZone) % 24 + 24) %24;
|
tzset();
|
||||||
|
|
||||||
|
time_t nowSecs = time(nullptr);
|
||||||
|
localtime_r(&nowSecs, &timeinfo);
|
||||||
|
|
||||||
// fill in the digits
|
// fill in the digits
|
||||||
timeDigits[0] = timeinfo.tm_min % 10; //minutes (units)
|
timeDigits[0] = timeinfo.tm_min % 10; //minutes (units)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
|
|
||||||
// To get vars from main file
|
// To get vars from main file
|
||||||
extern int timeZone;
|
extern char *timeZone;
|
||||||
extern char calName[5][31];
|
extern char calName[5][31];
|
||||||
extern char calStart[5][26];
|
extern char calStart[5][26];
|
||||||
extern char calTitle[5][81];
|
extern char calTitle[5][81];
|
||||||
|
|
Loading…
Reference in New Issue