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();
};
JS扩展
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- js 扩展:静态类型检查(facebook flow) js 语言与 java、C 系列等语言有一点很大的不同,就...
- 在项目中使用 bootstrap fileinput.js作为文件上传插件的过程中,需求提出如果文件名中包含某些特...
- 系统提供的导航是能满足绝大多数需求的,但有些时候需要我们自定制导航,比如: 1.导航的子视图过于复杂 2.前后两个...