refactor: remove Date.Format() method

0.2.5(deprecated)
SukkaW 7 years ago
parent 1686cc6873
commit f27cadfb92

@ -39,7 +39,7 @@
let setLS = (key, value) => { let setLS = (key, value) => {
try { try {
localStorage.setItem(key, value) localStorage.setItem(key, value);
} catch (o) { } catch (o) {
console.log(o + " Failed to set localStorage item"); console.log(o + " Failed to set localStorage item");
} }
@ -47,43 +47,13 @@
getLS = (key) => { getLS = (key) => {
return localStorage.getItem(key); return localStorage.getItem(key);
}; },
/* dateFormat = (date) => {
* Name: Date.Format() return `${date.getUTCFullYear().toString()}/${(date.getUTCMonth() + 1).toString()}/${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}:${date.getUTCSeconds()}`
* //yyyy-MM-dd hh:mm:ss
* Usage:
* Month - M | MM
* Date - d | dd
* Hour - h | hh
* Minute - m | mm
* Second - s | ss
* Season - q | qq
* Year - y | yy | yyyy
* ms - S
*
* Example: (new Date()).Format("yyyy-MM-dd hh:mm:ss.S")
*/
Date.prototype.Format = function (fmt) { }
var o = {
"M+": this.getMonth() + 1, // Minth
"d+": this.getDate(), // Date
"h+": this.getHours(), // Hour
"m+": this.getMinutes(), // Minute
"s+": this.getSeconds(), // Second
"q+": Math.floor((this.getMonth() + 3) / 3), // Season
"S": this.getMilliseconds() // ms
};
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;
}
/* /*
* Name: loadDisqus() * Name: loadDisqus()
@ -201,16 +171,6 @@
}; };
} }
/*
* Name: initThread()
* Description: init the thread when it is not
* API URI: /3.0/posts/list.json?forum=[shortname]&thread=[thread id]&api_key=[apikey]
*/
/* let initThread = () => {
} */
/* /*
* Name: getComment() * Name: getComment()
* Description: get the comment content * Description: get the comment content
@ -304,13 +264,13 @@
<header class="dsqjs-header"> <header class="dsqjs-header">
<span class="dsqjs-author">${s.authorEl}</span> <span class="dsqjs-author">${s.authorEl}</span>
<span class="dsqjs-bullet"></span> <span class="dsqjs-bullet"></span>
<span class="dsqjs-meta"><time>${(new Date(s.createdAt)).Format("yyyy-MM-dd hh:mm:ss")}</time></span> <span class="dsqjs-meta"><time>${dateFormat(new Date(s.createdAt))}</time></span>
</header> </header>
<div class="dsqjs-content">${s.message}</div> <div class="dsqjs-content">${s.message}</div>
</div> </div>
</div> </div>
*/ */
let commentItemTpl = `<div class="dsqjs-item-container"><div class="dsqjs-avater">${s.avatarEl}</div><div class="dsqjs-body"><header class="dsqjs-header"><span class="dsqjs-author">${s.authorEl}</span><span class="dsqjs-bullet"></span><span class="dsqjs-meta"><time>${(new Date(s.createdAt)).Format("yyyy-MM-dd hh:mm:ss")}</time></span></header><div class="dsqjs-content">${s.message}</div></div></div>` let commentItemTpl = `<div class="dsqjs-item-container"><div class="dsqjs-avater">${s.avatarEl}</div><div class="dsqjs-body"><header class="dsqjs-header"><span class="dsqjs-author">${s.authorEl}</span><span class="dsqjs-bullet"></span><span class="dsqjs-meta"><time>${dateFormat(new Date(s.createdAt))}</time></span></header><div class="dsqjs-content">${s.message}</div></div></div>`
return commentItemTpl return commentItemTpl
} }

Loading…
Cancel
Save