String.prototype.replaceAll = function (oldStr, newStr) {
var sourceStr = this.valueOf();
while (sourceStr.indexOf(oldStr) !== -1) {
sourceStr = sourceStr.replace(oldStr, newStr);
}
return sourceStr;
};
Date.prototype.monthDay = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Date.prototype.weekName = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
Date.prototype.addDay = function () {
return this.addDays(1);
};
Date.prototype.addDays = function (days) {
this.setTime(this.getTime() + 1000 * 60 * 60 * 24 * days);
};
/*判断某年某月某日是星期几,默认日为1号*/
Date.prototype.getWeek = function () {
return this.weekName[this.getDay()];
};
/*判断某年是否是闰年*/
Date.prototype.getLeap = function (year) {
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
return 29;
} else {
return 28;
}
};
Date.prototype.equal = function (d) {
return this.getFullYear() == d.getFullYear() && this.getMonth() == d.getMonth() && this.getDate() == d.getDate();
};
Date.prototype.toDateString = function () {
return this.getFullYear() + "-" + (this.getMonth() + 1) + "-" + this.getDate();
};
网友评论