😪 js-standard

This commit is contained in:
zuiidea
2017-01-03 16:15:38 +08:00
parent 49d700a5c8
commit 87af30c4b6
50 changed files with 783 additions and 858 deletions
+15 -14
View File
@@ -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
}