Set up scheduled program cycles #24
|
@ -65,9 +65,27 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
<title>ESP Input Form</title>
|
<title>ESP Input Form</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
// Utility from https://webreflection.medium.com/using-the-input-datetime-local-9503e7efdce
|
||||||
|
Date.prototype.toDatetimeLocal = function toDatetimeLocal() {
|
||||||
|
var
|
||||||
|
date = this,
|
||||||
|
ten = function (i) {
|
||||||
|
return (i < 10 ? '0' : '') + i;
|
||||||
|
},
|
||||||
|
YYYY = date.getFullYear(),
|
||||||
|
MM = ten(date.getMonth() + 1),
|
||||||
|
DD = ten(date.getDate()),
|
||||||
|
HH = ten(date.getHours()),
|
||||||
|
II = ten(date.getMinutes()),
|
||||||
|
SS = ten(date.getSeconds())
|
||||||
|
;
|
||||||
|
return YYYY + '-' + MM + '-' + DD + 'T' +
|
||||||
|
HH + ':' + II + ':' + SS;
|
||||||
|
}
|
||||||
|
|
||||||
// Submit timestamps as unix seconds
|
// Submit timestamps as unix seconds
|
||||||
var putDate = function(form) {
|
var putDate = function(form) {
|
||||||
form.inputTimeUnix.value = Math.floor(Date.now() / 1000) - new Date().getTimezoneOffset()*60;
|
form.inputTimeUnix.value = Math.floor(Date.now() / 1000);// - new Date().getTimezoneOffset()*60;
|
||||||
form.inputStartTimeUnix.value = ((Date.parse(js_start_time_unix_entry.value))/1000);
|
form.inputStartTimeUnix.value = ((Date.parse(js_start_time_unix_entry.value))/1000);
|
||||||
//document.getElementById("js_start_time_unix").value = ((Date.parse(js_start_time_unix_entry.value))/1000);
|
//document.getElementById("js_start_time_unix").value = ((Date.parse(js_start_time_unix_entry.value))/1000);
|
||||||
}
|
}
|
||||||
|
@ -79,13 +97,13 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
// Current start date to string
|
// Current start date to string
|
||||||
s = %inputStartTimeUnix%;
|
s = %inputStartTimeUnix%;
|
||||||
current_start = new Date(s * 1000);
|
current_start = new Date(s * 1000);
|
||||||
//current_start_utc = current_start.toUTCString();
|
document.getElementById('current-start').innerHTML = current_start.toLocaleString();
|
||||||
document.getElementById('current-start').innerHTML = current_start.toString();
|
// Show the local time as a string
|
||||||
// Show the local time
|
local_time_unix = new Date().toLocaleString();//toUTCString();
|
||||||
local_time_unix = new Date().toString();
|
|
||||||
document.getElementById('local-time-unix').innerHTML = local_time_unix.toString();
|
document.getElementById('local-time-unix').innerHTML = local_time_unix.toString();
|
||||||
// fill in the start time field
|
// fill in the start time field as local time
|
||||||
document.getElementById('js_start_time_unix_entry').value = current_start.toISOString().slice(0,16);
|
//document.getElementById('js_start_time_unix_entry').value = current_start.toISOString().slice(0,16);
|
||||||
|
document.getElementById('js_start_time_unix_entry').value = current_start.toDatetimeLocal();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script></head><body>
|
</script></head><body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user