mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-23 06:00:24 +00:00
😪 js-standard
This commit is contained in:
+15
-14
@@ -15,28 +15,29 @@ String.prototype.hyphenToHump = function () {
|
||||
|
||||
// 驼峰转连字符
|
||||
String.prototype.humpToHyphen = function () {
|
||||
return this.replace(/([A-Z])/g, "-$1").toLowerCase()
|
||||
return this.replace(/([A-Z])/g, '-$1').toLowerCase()
|
||||
}
|
||||
|
||||
// 日期格式化
|
||||
Date.prototype.format = function (format) {
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1,
|
||||
"d+": this.getDate(),
|
||||
"h+": this.getHours(),
|
||||
'M+': this.getMonth() + 1,
|
||||
'd+': this.getDate(),
|
||||
'h+': this.getHours(),
|
||||
'H+': this.getHours(),
|
||||
"m+": this.getMinutes(),
|
||||
"s+": this.getSeconds(),
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3),
|
||||
"S": this.getMilliseconds()
|
||||
'm+': this.getMinutes(),
|
||||
's+': this.getSeconds(),
|
||||
'q+': Math.floor((this.getMonth() + 3) / 3),
|
||||
'S': this.getMilliseconds()
|
||||
}
|
||||
if (/(y+)/.test(format))
|
||||
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(format))
|
||||
format = format.replace(RegExp.$1, RegExp.$1.length == 1
|
||||
if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) }
|
||||
for (var k in o) {
|
||||
if (new RegExp('(' + k + ')').test(format)) {
|
||||
format = format.replace(RegExp.$1, RegExp.$1.length === 1
|
||||
? o[k]
|
||||
: ("00" + o[k]).substr(("" + o[k]).length))
|
||||
: ('00' + o[k]).substr(('' + o[k]).length))
|
||||
}
|
||||
}
|
||||
return format
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user