mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-14 14:08:19 +08:00
在前端格式化时间
This commit is contained in:
@@ -157,15 +157,10 @@ exit:
|
|||||||
static int HttpGetTc1Status(httpd_request_t *req)
|
static int HttpGetTc1Status(httpd_request_t *req)
|
||||||
{
|
{
|
||||||
char* sockets = GetSocketStatus();
|
char* sockets = GetSocketStatus();
|
||||||
char* tc1_status = malloc(458);
|
char* tc1_status = malloc(412);
|
||||||
char now_date[11] = { 0 };
|
|
||||||
char now_time[10] = { 0 };
|
|
||||||
strftime(now_date, 11, "%Y-%m-%d", localtime(&now));
|
|
||||||
strftime(now_time, 10, "%H:%M:%S", localtime(&now));
|
|
||||||
sprintf(tc1_status, TC1_STATUS_JSON, sockets, ip_status.mode,
|
sprintf(tc1_status, TC1_STATUS_JSON, sockets, ip_status.mode,
|
||||||
sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key,
|
sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key,
|
||||||
user_config->ap_name, user_config->ap_key, MQTT_SERVER, MQTT_SERVER_PORT, VERSION,
|
user_config->ap_name, user_config->ap_key, MQTT_SERVER, MQTT_SERVER_PORT, VERSION, ip_status.ip, ip_status.mask, ip_status.gateway, 0L);
|
||||||
ip_status.ip, ip_status.mask, ip_status.gateway, now_date, now_time, 0L);
|
|
||||||
|
|
||||||
OSStatus err = kNoErr;
|
OSStatus err = kNoErr;
|
||||||
send_http(tc1_status, strlen(tc1_status), exit, &err);
|
send_http(tc1_status, strlen(tc1_status), exit, &err);
|
||||||
|
|||||||
@@ -60,8 +60,6 @@
|
|||||||
'ip':'%s',\
|
'ip':'%s',\
|
||||||
'mask':'%s',\
|
'mask':'%s',\
|
||||||
'gateway':'%s',\
|
'gateway':'%s',\
|
||||||
'date':'%s',\
|
|
||||||
'time':'%s',\
|
|
||||||
'up_time':%ld\
|
'up_time':%ld\
|
||||||
}"
|
}"
|
||||||
|
|
||||||
|
|||||||
@@ -559,6 +559,28 @@ function HttpDel(url, onsuccess, data) {
|
|||||||
}
|
}
|
||||||
//Ajax-end
|
//Ajax-end
|
||||||
|
|
||||||
|
//DateTool-start
|
||||||
|
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
|
||||||
|
// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
|
||||||
|
Date.prototype.Format = function(fmt) {
|
||||||
|
var o = {
|
||||||
|
"M+" : this.getMonth()+1, //月份
|
||||||
|
"d+" : this.getDate(), //日
|
||||||
|
"h+" : this.getHours(), //小时
|
||||||
|
"m+" : this.getMinutes(), //分
|
||||||
|
"s+" : this.getSeconds(), //秒
|
||||||
|
"q+" : Math.floor((this.getMonth()+3)/3), //季度
|
||||||
|
"S" : this.getMilliseconds() //毫秒
|
||||||
|
};
|
||||||
|
if(/(y+)/.test(fmt))
|
||||||
|
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
|
||||||
|
for(var k in o)
|
||||||
|
if(new RegExp("("+ k +")").test(fmt))
|
||||||
|
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
|
||||||
|
return fmt;
|
||||||
|
}
|
||||||
|
//DateTool-end
|
||||||
|
|
||||||
var info_station_name;
|
var info_station_name;
|
||||||
var info_wifi_password;
|
var info_wifi_password;
|
||||||
var mqtt_addr;
|
var mqtt_addr;
|
||||||
@@ -593,14 +615,6 @@ HttpGet("/status", function (re) {
|
|||||||
$("#info_mask").html(status.mask);
|
$("#info_mask").html(status.mask);
|
||||||
$("#info_gateway").html(status.gateway);
|
$("#info_gateway").html(status.gateway);
|
||||||
$("#uptime").html(status.up_time);
|
$("#uptime").html(status.up_time);
|
||||||
|
|
||||||
//var now = new Date()
|
|
||||||
//task_date.value = now.toLocaleDateString().replace(/\//g, '-');
|
|
||||||
//task_date.value = now.getFullYear() + '-' + now.getMonth() + '-' + now.getDate();
|
|
||||||
$("#task_date").value(status.date);
|
|
||||||
$("#task_time").value(status.time);
|
|
||||||
task_date.value = status.date;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Menu-start
|
//Menu-start
|
||||||
@@ -846,8 +860,10 @@ GetTimedTask();
|
|||||||
|
|
||||||
var task_date = document.getElementById("task_date");
|
var task_date = document.getElementById("task_date");
|
||||||
var task_time = document.getElementById("task_time");
|
var task_time = document.getElementById("task_time");
|
||||||
task_date.value = "2020-12-31";
|
//task_date.value = "2020-12-31";
|
||||||
task_time.value = "10:08:00";
|
//task_time.value = "10:08:00";
|
||||||
|
task_date.value = (new Date()).Format("yyyy-MM-dd");
|
||||||
|
task_time.value = (new Date()).Format("hh:mm:00");
|
||||||
function AddTimedTask() {
|
function AddTimedTask() {
|
||||||
var dat = task_date.value;
|
var dat = task_date.value;
|
||||||
var tim = task_time.value;
|
var tim = task_time.value;
|
||||||
|
|||||||
Reference in New Issue
Block a user