MCPcopy Index your code
hub / github.com/TruthHun/BookStack / dateFormat

Function dateFormat

static/js/bookstack.js:111–129  ·  view source on GitHub ↗
(fmt, date)

Source from the content-addressed store, hash-verified

109}
110
111function dateFormat(fmt, date) {
112 var ret;
113 const opt = {
114 "Y+": date.getFullYear().toString(), // 年
115 "m+": (date.getMonth() + 1).toString(), // 月
116 "d+": date.getDate().toString(), // 日
117 "H+": date.getHours().toString(), // 时
118 "M+": date.getMinutes().toString(), // 分
119 "S+": date.getSeconds().toString() // 秒
120 // 有其他格式化字符需求可以继续添加,必须转化成字符串
121 };
122 for (let k in opt) {
123 ret = new RegExp("(" + k + ")").exec(fmt);
124 if (ret) {
125 fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
126 };
127 };
128 return fmt;
129}
130
131function initHighlighting() {
132 $('pre code').each(function (i, block) {

Callers 1

initCommentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected