github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/cmd/jsjob/jsjob.js (about) 1 //扩展方法 2 // Date.prototype.Add = function (seconds) { var t = new Date(); t.setTime(this.getTime() + seconds * 1000); return t; }; 3 // Date.prototype.AddDate = Date.prototype.AddDays = function (days) { var t = new Date(); t.setTime(this.getTime() + days * 24 * 3600 * 1000); return t; }; 4 // Date.prototype.Date = function () { return this.toISOString().split("T")[0]; }; 5 Date.prototype.Time = function () { return this.toISOString().split("T")[1].split(".")[0]; }; 6 // Date.prototype.DateTime = function () { return this.toISOString().replace("T", " ").split(".")[0]; }; 7 // String.prototype.Date = function () { return this.replace("T", " ").split(" ")[0]; }; 8 // String.prototype.Time = function () { return this.replace("T", " ").split(" ")[1].split(".")[0]; }; 9 // String.prototype.DateTime = function () { return this.replace("T", " ").split(".")[0]; }; 10 // function col(s) { if (!s) { return "NULL"; } return "'" + s.replace("'", "''") + "'"; }; 11 12 //配置计划任务 13 cron = [ 14 { 15 name: "001", 16 spec: "* * * * *", // every minutes 17 func: function () { 18 $.trace = true; // 反代接口 URL调试 19 var bSubject = nats.subject + "-"; // 反代消息 注意后缀 20 var item = { Subject: bSubject, Time: new Date().Time() }; 21 item.ActionName = '反代接口'; 22 var res = $.q("post", "https://postman-echo.com/post", item, "url"); 23 // dump(res); 24 } 25 }, 26 ];