|
|
@ -20887,16 +20887,17 @@ Date.prototype.getDayOfYear = function () { |
|
|
|
Date.prototype.getWeekNumber = function () { |
|
|
|
Date.prototype.getWeekNumber = function () { |
|
|
|
var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); |
|
|
|
var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); |
|
|
|
//周一是一周第一天
|
|
|
|
//周一是一周第一天
|
|
|
|
var week = d.getDay(); |
|
|
|
var week = d.getDay() === 0 ? 7 : d.getDay(); |
|
|
|
|
|
|
|
//var week = d.getDay();
|
|
|
|
if (this.getMonth() === 0 && this.getDate() <= week) { |
|
|
|
if (this.getMonth() === 0 && this.getDate() <= week) { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
d.setDate(this.getDate() - week); |
|
|
|
d.setDate(this.getDate() - (week - 1)); |
|
|
|
var ms = d.valueOf(); // GMT
|
|
|
|
var ms = d.valueOf(); // GMT
|
|
|
|
d.setMonth(0); |
|
|
|
d.setMonth(0); |
|
|
|
d.setDate(1); |
|
|
|
d.setDate(1); |
|
|
|
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; |
|
|
|
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; |
|
|
|
if (d.getDay() > 0) { |
|
|
|
if (d.getDay() !== 1) { |
|
|
|
offset++; |
|
|
|
offset++; |
|
|
|
} |
|
|
|
} |
|
|
|
return offset; |
|
|
|
return offset; |
|
|
@ -20976,13 +20977,12 @@ Date.prototype.getOffsetMonth = function (n) { |
|
|
|
//获得本周的起始日期
|
|
|
|
//获得本周的起始日期
|
|
|
|
Date.prototype.getWeekStartDate = function () { |
|
|
|
Date.prototype.getWeekStartDate = function () { |
|
|
|
var w = this.getDay(); |
|
|
|
var w = this.getDay(); |
|
|
|
return this.getOffsetDate(-w); |
|
|
|
return this.getOffsetDate(w === 0 ? -6 : 1 - w); |
|
|
|
}; |
|
|
|
}; |
|
|
|
//得到本周的结束日期
|
|
|
|
//得到本周的结束日期
|
|
|
|
Date.prototype.getWeekEndDate = function () { |
|
|
|
Date.prototype.getWeekEndDate = function () { |
|
|
|
var w = this.getDay(); |
|
|
|
var w = this.getDay(); |
|
|
|
var offset = (w === 0 ? 6 : 6 - w); |
|
|
|
return this.getOffsetDate(w === 0 ? 0 : 7 - w); |
|
|
|
return this.getOffsetDate(offset); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** Checks date and time equality */ |
|
|
|
/** Checks date and time equality */ |
|
|
|