diff --git a/TC1/http_server/app_httpd.c b/TC1/http_server/app_httpd.c index ae1a00d..e423e31 100644 --- a/TC1/http_server/app_httpd.c +++ b/TC1/http_server/app_httpd.c @@ -157,15 +157,10 @@ exit: static int HttpGetTc1Status(httpd_request_t *req) { char* sockets = GetSocketStatus(); - char* tc1_status = malloc(458); - 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)); + char* tc1_status = malloc(412); sprintf(tc1_status, TC1_STATUS_JSON, sockets, ip_status.mode, sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key, - user_config->ap_name, user_config->ap_key, MQTT_SERVER, MQTT_SERVER_PORT, VERSION, - ip_status.ip, ip_status.mask, ip_status.gateway, now_date, now_time, 0L); + user_config->ap_name, user_config->ap_key, MQTT_SERVER, MQTT_SERVER_PORT, VERSION, ip_status.ip, ip_status.mask, ip_status.gateway, 0L); OSStatus err = kNoErr; send_http(tc1_status, strlen(tc1_status), exit, &err); diff --git a/TC1/http_server/app_httpd.h b/TC1/http_server/app_httpd.h index de10159..92b0171 100644 --- a/TC1/http_server/app_httpd.h +++ b/TC1/http_server/app_httpd.h @@ -60,8 +60,6 @@ 'ip':'%s',\ 'mask':'%s',\ 'gateway':'%s',\ - 'date':'%s',\ - 'time':'%s',\ 'up_time':%ld\ }" diff --git a/TC1/http_server/web/index.html b/TC1/http_server/web/index.html index 740cc3b..a98e491 100644 --- a/TC1/http_server/web/index.html +++ b/TC1/http_server/web/index.html @@ -559,6 +559,28 @@ function HttpDel(url, onsuccess, data) { } //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_wifi_password; var mqtt_addr; @@ -593,14 +615,6 @@ HttpGet("/status", function (re) { $("#info_mask").html(status.mask); $("#info_gateway").html(status.gateway); $("#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 @@ -846,8 +860,10 @@ GetTimedTask(); var task_date = document.getElementById("task_date"); var task_time = document.getElementById("task_time"); -task_date.value = "2020-12-31"; -task_time.value = "10:08:00"; +//task_date.value = "2020-12-31"; +//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() { var dat = task_date.value; var tim = task_time.value;