This commit is contained in:
zuiidea
2016-12-14 23:11:56 +08:00
parent 67dd886130
commit e9c361a8a9
5 changed files with 245 additions and 51 deletions
+24 -2
View File
@@ -15,7 +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(),
'H+': this.getHours(),
"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
? o[k]
: ("00" + o[k]).substr(("" + o[k]).length))
return format
}
module.exports = {
@@ -23,5 +45,5 @@ module.exports = {
menu,
request,
color,
classnames,
classnames
}