MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / getTime

Function getTime

public/iframe/lib/js/commonFun.js:494–510  ·  view source on GitHub ↗
(type, hhmmss)

Source from the content-addressed store, hash-verified

492 }
493 },
494 getTime(type, hhmmss) {
495 // type =0 为当天 type = 1 为前一天
496 // hhmmss 自己传需要的时分秒
497 const now = new Date();
498 let date
499 if (type === 0) {
500 date = new Date(now + 8 * 3600 * 1000); // 增加8小时 当天
501 } else {
502 const now = new Date();
503 date = new Date(now - 3 * type * 8 * 3600 * 1000); // type天前
504 }
505 if (hhmmss) {
506 return `${date.toJSON().substr(0, 19).replace('T', ' ').substring(0, 10)} ${hhmmss}`;
507 }
508 return `${date.toJSON().substr(0, 19).replace('T', ' ').substring(0, 10)}`;
509
510 },
511 fixParamsTime(params) {
512 // 如果params中存在时间查询 因 参数里面不可获取当前时间 因此这里对约定的特殊字符进行获取替换
513 // #0,23:59:29# 当天结束 #5,00:00:00# 五天前

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected