diff --git a/bi/core.js b/bi/core.js index 32390d7e0..0ea460553 100644 --- a/bi/core.js +++ b/bi/core.js @@ -6389,6 +6389,19 @@ Date.prototype.getOffsetMonth = function (n) { return dt; }; +//获得本周的起始日期 +Date.prototype.getWeekStartDate = function () { + var w = this.getDay(); + var offset = (w === 0 ? 7 : w); + return this.getOffsetDate(1 - offset); +}; +//得到本周的结束日期 +Date.prototype.getWeekEndDate = function () { + var w = this.getDay(); + var offset = (w === 0 ? 0 : 7 - w); + return this.getOffsetDate(offset); +}; + //获得本季度的起始日期 Date.prototype.getQuarterStartDate = function () { return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); diff --git a/docs/core.js b/docs/core.js index 4631967d7..bb99b48a9 100644 --- a/docs/core.js +++ b/docs/core.js @@ -23872,6 +23872,19 @@ Date.prototype.getOffsetMonth = function (n) { return dt; }; +//获得本周的起始日期 +Date.prototype.getWeekStartDate = function () { + var w = this.getDay(); + var offset = (w === 0 ? 7 : w); + return this.getOffsetDate(1 - offset); +}; +//得到本周的结束日期 +Date.prototype.getWeekEndDate = function () { + var w = this.getDay(); + var offset = (w === 0 ? 0 : 7 - w); + return this.getOffsetDate(offset); +}; + //获得本季度的起始日期 Date.prototype.getQuarterStartDate = function () { return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); diff --git a/src/core/proto/date.js b/src/core/proto/date.js index e3146708b..f105cae42 100644 --- a/src/core/proto/date.js +++ b/src/core/proto/date.js @@ -196,6 +196,19 @@ Date.prototype.getOffsetMonth = function (n) { return dt; }; +//获得本周的起始日期 +Date.prototype.getWeekStartDate = function () { + var w = this.getDay(); + var offset = (w === 0 ? 7 : w); + return this.getOffsetDate(1 - offset); +}; +//得到本周的结束日期 +Date.prototype.getWeekEndDate = function () { + var w = this.getDay(); + var offset = (w === 0 ? 0 : 7 - w); + return this.getOffsetDate(offset); +}; + //获得本季度的起始日期 Date.prototype.getQuarterStartDate = function () { return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1);