timezone improvements

This commit is contained in:
Paul
2019-11-03 11:05:49 +01:00
parent 6275245b03
commit cd7e918690
6 changed files with 19 additions and 17 deletions

View File

@@ -2467,7 +2467,7 @@ void MyESP::_onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, A
// handle ws from browser
void MyESP::_procMsg(AsyncWebSocketClient * client, size_t sz) {
// We should always get a JSON object from browser, so parse it
StaticJsonDocument<400> doc;
StaticJsonDocument<500> doc;
char json[sz + 1];
memcpy(json, (char *)(client->_tempObject), sz);
json[sz] = '\0';

View File

@@ -13,6 +13,12 @@ IPAddress NtpClient::timeServer;
AsyncUDP NtpClient::udpListener;
byte NtpClient::NTPpacket[NTP_PACKET_SIZE];
// references:
// https://github.com/filipdanic/compact-timezone-list/blob/master/index.js
// 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
// Australia Eastern Time Zone (Sydney, Melbourne)
TimeChangeRule aEDT = {"AEDT", First, Sun, Oct, 2, 660}; // UTC + 11 hours
TimeChangeRule aEST = {"AEST", First, Sun, Apr, 3, 600}; // UTC + 10 hours

View File

@@ -212,7 +212,7 @@
</div>
</div>
<div style="clear:both;">
<br>
<br>
</div>
<div>
<div class="form-group">

View File

@@ -338,22 +338,21 @@
<div id="ntpcontent">
<br>
<legend>Time Settings</legend>
<h6 class="text-muted">With Network Time Protocol (NTP) enabled, all times are adjusted to the local timezone
and
respect daylight saving
time (DST)</h6>
<h6 class="text-muted">With Network Time Protocol (NTP) enabled, all times are adjusted to the local timezone and
respect daylight saving time (DST)</h6>
<br>
<div class="row form-group">
<label class="col-xs-3">Device Time</label>
<span id="utc" class="col-xs-9 col-md-5">
</span>
<span id="utc" class="col-xs-9 col-md-5"></span>
<div class="col-xs-3">
<button onclick="forcentp()" id="forcentp" class="btn btn-info btn-sm">Sync Device with Internet
Time</button>
</div>
</div>
<div class="row form-group">
<label class="col-xs-3">Browser Time</label>
<span id="rtc" class="col-xs-9 col-md-5">
</span>
</div>
<div class="row form-group">
<span id="rtc" class="col-xs-9 col-md-5"></span>
<div class="col-xs-3">
<button onclick="syncBrowserTime()" class="btn btn-info btn-sm">Sync Browser Time to Device</button><i
style="margin-left: 10px;" class="glyphicon glyphicon-info-sign" aria-hidden="true"
@@ -361,6 +360,7 @@
data-content="Use your browser time. Useful when the system does not have an internet connection."></i>
</div>
</div>
<div class="row form-group">
<label class="col-xs-3">NTP<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
@@ -372,8 +372,6 @@
<label class="radio-inline">
<input type="radio" value="0" onclick="handleNTPOFF();" name="ntpenabled" checked>Disabled</label>
</form>
<button onclick="forcentp()" id="forcentp" class="btn btn-info btn-sm">Sync Device with Internet
Time</button>
</div>
</div>
<div class="row form-group">

View File

@@ -715,8 +715,6 @@ function initMQTTLogTable() {
if (value < 1563300000) {
return "(" + value + ")";
} else {
var comp = new Date();
value = Math.floor(value + ((comp.getTimezoneOffset() * 60) * -1));
var vuepoch = new Date(value * 1000);
var formatted = vuepoch.getUTCFullYear() +
"-" + twoDigits(vuepoch.getUTCMonth() + 1) +

View File

@@ -89,7 +89,7 @@ var configfile = {
"server": "pool.ntp.org",
"interval": 60,
"timezone": 2,
"enabled": false
"enabled": true
}
};