Skip to content

Commit

Permalink
fix timezone offset (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
osresearch committed Oct 2, 2020
1 parent 1bce9fe commit 76a8c20
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions overtime/overtime.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <ArduinoWebsockets.h> // 0.4.18
#include <ESP8266WiFi.h>
#include "time.h"
#include <TZ.h>
#include "Adafruit_EPD.h" // 2.5.3
#include "Adafruit_GFX.h" // 1.10.1
#include "GVB.h"
Expand Down Expand Up @@ -153,7 +154,6 @@ static void draw_time(void)
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm *tm = localtime(&tv.tv_sec);
//struct tm *tm = gmtime(&tv.tv_sec);

display.setRotation(0);
//display.setFont(&small_font);
Expand All @@ -163,7 +163,7 @@ static void draw_time(void)
tm->tm_year + 1900,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour + 1,
tm->tm_hour,
tm->tm_min,
tm->tm_sec
);
Expand Down Expand Up @@ -203,11 +203,7 @@ void setup() {
display.print(WiFi.localIP());

printf("configuring ntp\r\n");
configTime(1, 3600, "pool.ntp.org");

// force the timezone to be Amsterdam time
setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 3);
tzset();
configTime(TZ_Europe_Amsterdam, "pool.ntp.org");

draw_time();
display.display();
Expand Down

0 comments on commit 76a8c20

Please sign in to comment.