From 17dc48b376fdb7f1c0387776bb687d64689b4e36 Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 4 Nov 2019 19:15:45 +0100 Subject: [PATCH] added Turkey as timezone --- src/Ntp.cpp | 11 ++++++++--- src/Ntp.h | 4 ++-- src/websrc/myesp.htm | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Ntp.cpp b/src/Ntp.cpp index 156184972..4d7e8cea7 100644 --- a/src/Ntp.cpp +++ b/src/Ntp.cpp @@ -18,6 +18,7 @@ byte NtpClient::NTPpacket[NTP_PACKET_SIZE]; // https://github.com/sanohin/google-timezones-json/blob/master/timezones.json // https://github.com/dmfilipenko/timezones.json/blob/master/timezones.json // https://home.kpn.nl/vanadovv/time/TZworld.html +// https://www.timeanddate.com/time/zones/ // Australia Eastern Time Zone (Sydney, Melbourne) TimeChangeRule aEDT = {"AEDT", First, Sun, Oct, 2, 660}; // UTC + 11 hours @@ -26,7 +27,11 @@ Timezone ausET(aEDT, aEST); // Moscow Standard Time (MSK, does not observe DST) TimeChangeRule msk = {"MSK", Last, Sun, Mar, 1, 180}; -Timezone tzMSK(msk); +Timezone MSK(msk); + +// Turkey +TimeChangeRule trt = {"TRT", Last, Sun, Mar, 1, 180}; +Timezone TRT(trt); // Central European Time (Frankfurt, Paris) TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; // Central European Summer Time @@ -66,14 +71,14 @@ TimeChangeRule usPST = {"PST", First, Sun, Nov, 2, -480}; Timezone usPT(usPDT, usPST); // build index of all timezones -Timezone * timezones[] = {&ausET, &tzMSK, &CE, &UK, &UTC, &usET, &usCT, &usMT, &usAZ, &usPT}; +Timezone * timezones[] = {&ausET, &MSK, &CE, &UK, &UTC, &usET, &usCT, &usMT, &usAZ, &usPT, &TRT}; void ICACHE_FLASH_ATTR NtpClient::Ntp(const char * server, time_t syncMins, uint8_t tz_index) { TimeServerName = strdup(server); syncInterval = syncMins * 60; // convert to seconds // check for out of bounds - if (tz_index > NTP_TIMEZONE_MAX) { + if (tz_index >= NTP_TIMEZONE_MAX) { tz_index = NTP_TIMEZONE_DEFAULT; } tz = timezones[tz_index]; // set timezone diff --git a/src/Ntp.h b/src/Ntp.h index 03bb88946..92f5cf680 100644 --- a/src/Ntp.h +++ b/src/Ntp.h @@ -13,10 +13,10 @@ #include "TimeLib.h" // customized version of the Time library #include "Timezone.h" -#define NTP_PACKET_SIZE 48 // NTP time is in the first 48 bytes of message +#define NTP_PACKET_SIZE 48 // NTP time is in the first 48 bytes of the message #define NTP_INTERVAL_DEFAULT 60 // every hour #define NTP_TIMEZONE_DEFAULT 2 // CE -#define NTP_TIMEZONE_MAX 9 +#define NTP_TIMEZONE_MAX 11 class NtpClient { public: diff --git a/src/websrc/myesp.htm b/src/websrc/myesp.htm index 963e79ce6..32d5a397d 100644 --- a/src/websrc/myesp.htm +++ b/src/websrc/myesp.htm @@ -408,6 +408,7 @@ +