From 0d8f1df26d7dad7755278fd480aebfb238bd549c Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 24 Apr 2017 11:48:17 +0800 Subject: [PATCH] update --- bi/core.js | 98 ++++++++++++++++++++++++++++++++++++++++++ docs/core.js | 98 ++++++++++++++++++++++++++++++++++++++++++ src/core/proto/date.js | 98 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) diff --git a/bi/core.js b/bi/core.js index 0c0d0099b..db3206894 100644 --- a/bi/core.js +++ b/bi/core.js @@ -6264,6 +6264,104 @@ Date.prototype.getOffsetDate = function (offset) { return new Date(this.getTime() + offset * 864e5); }; +Date.prototype.getAfterMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n * 3); + return dt; +}; +//获得n个季度前的日期 +Date.prototype.getBeforeMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n * 3); + return dt; +}; +//得到本季度的起始月份 +Date.prototype.getQuarterStartMonth = function () { + var quarterStartMonth = 0; + var nowMonth = this.getMonth(); + if (nowMonth < 3) { + quarterStartMonth = 0; + } + if (2 < nowMonth && nowMonth < 6) { + quarterStartMonth = 3; + } + if (5 < nowMonth && nowMonth < 9) { + quarterStartMonth = 6; + } + if (nowMonth > 8) { + quarterStartMonth = 9; + } + return quarterStartMonth; +}; +//获得本季度的起始日期 +Date.prototype.getQuarterStartDate = function () { + return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); +}; +//得到本季度的结束日期 +Date.prototype.getQuarterEndDate = function () { + var quarterEndMonth = this.getQuarterStartMonth() + 2; + return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); +}; +Date.prototype.getAfterMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n | 0); + return dt; +}; +Date.prototype.getBeforeMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n | 0); + return dt; +}; + +Date.prototype.getAfterMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n * 3); + return dt; +}; +//获得n个季度前的日期 +Date.prototype.getBeforeMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n * 3); + return dt; +}; +//得到本季度的起始月份 +Date.prototype.getQuarterStartMonth = function () { + var quarterStartMonth = 0; + var nowMonth = this.getMonth(); + if (nowMonth < 3) { + quarterStartMonth = 0; + } + if (2 < nowMonth && nowMonth < 6) { + quarterStartMonth = 3; + } + if (5 < nowMonth && nowMonth < 9) { + quarterStartMonth = 6; + } + if (nowMonth > 8) { + quarterStartMonth = 9; + } + return quarterStartMonth; +}; +//获得本季度的起始日期 +Date.prototype.getQuarterStartDate = function () { + return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); +}; +//得到本季度的结束日期 +Date.prototype.getQuarterEndDate = function () { + var quarterEndMonth = this.getQuarterStartMonth() + 2; + return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); +}; +Date.prototype.getAfterMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n | 0); + return dt; +}; +Date.prototype.getBeforeMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n | 0); + return dt; +}; + /** Checks date and time equality */ Date.prototype.equalsTo = function (date) { return ((this.getFullYear() == date.getFullYear()) && diff --git a/docs/core.js b/docs/core.js index 8a85d1efa..d8367ba60 100644 --- a/docs/core.js +++ b/docs/core.js @@ -23740,6 +23740,104 @@ Date.prototype.getOffsetDate = function (offset) { return new Date(this.getTime() + offset * 864e5); }; +Date.prototype.getAfterMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n * 3); + return dt; +}; +//获得n个季度前的日期 +Date.prototype.getBeforeMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n * 3); + return dt; +}; +//得到本季度的起始月份 +Date.prototype.getQuarterStartMonth = function () { + var quarterStartMonth = 0; + var nowMonth = this.getMonth(); + if (nowMonth < 3) { + quarterStartMonth = 0; + } + if (2 < nowMonth && nowMonth < 6) { + quarterStartMonth = 3; + } + if (5 < nowMonth && nowMonth < 9) { + quarterStartMonth = 6; + } + if (nowMonth > 8) { + quarterStartMonth = 9; + } + return quarterStartMonth; +}; +//获得本季度的起始日期 +Date.prototype.getQuarterStartDate = function () { + return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); +}; +//得到本季度的结束日期 +Date.prototype.getQuarterEndDate = function () { + var quarterEndMonth = this.getQuarterStartMonth() + 2; + return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); +}; +Date.prototype.getAfterMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n | 0); + return dt; +}; +Date.prototype.getBeforeMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n | 0); + return dt; +}; + +Date.prototype.getAfterMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n * 3); + return dt; +}; +//获得n个季度前的日期 +Date.prototype.getBeforeMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n * 3); + return dt; +}; +//得到本季度的起始月份 +Date.prototype.getQuarterStartMonth = function () { + var quarterStartMonth = 0; + var nowMonth = this.getMonth(); + if (nowMonth < 3) { + quarterStartMonth = 0; + } + if (2 < nowMonth && nowMonth < 6) { + quarterStartMonth = 3; + } + if (5 < nowMonth && nowMonth < 9) { + quarterStartMonth = 6; + } + if (nowMonth > 8) { + quarterStartMonth = 9; + } + return quarterStartMonth; +}; +//获得本季度的起始日期 +Date.prototype.getQuarterStartDate = function () { + return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); +}; +//得到本季度的结束日期 +Date.prototype.getQuarterEndDate = function () { + var quarterEndMonth = this.getQuarterStartMonth() + 2; + return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); +}; +Date.prototype.getAfterMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n | 0); + return dt; +}; +Date.prototype.getBeforeMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n | 0); + return dt; +}; + /** Checks date and time equality */ Date.prototype.equalsTo = function (date) { return ((this.getFullYear() == date.getFullYear()) && diff --git a/src/core/proto/date.js b/src/core/proto/date.js index d1c240377..755e488f0 100644 --- a/src/core/proto/date.js +++ b/src/core/proto/date.js @@ -104,6 +104,104 @@ Date.prototype.getOffsetDate = function (offset) { return new Date(this.getTime() + offset * 864e5); }; +Date.prototype.getAfterMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n * 3); + return dt; +}; +//获得n个季度前的日期 +Date.prototype.getBeforeMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n * 3); + return dt; +}; +//得到本季度的起始月份 +Date.prototype.getQuarterStartMonth = function () { + var quarterStartMonth = 0; + var nowMonth = this.getMonth(); + if (nowMonth < 3) { + quarterStartMonth = 0; + } + if (2 < nowMonth && nowMonth < 6) { + quarterStartMonth = 3; + } + if (5 < nowMonth && nowMonth < 9) { + quarterStartMonth = 6; + } + if (nowMonth > 8) { + quarterStartMonth = 9; + } + return quarterStartMonth; +}; +//获得本季度的起始日期 +Date.prototype.getQuarterStartDate = function () { + return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); +}; +//得到本季度的结束日期 +Date.prototype.getQuarterEndDate = function () { + var quarterEndMonth = this.getQuarterStartMonth() + 2; + return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); +}; +Date.prototype.getAfterMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n | 0); + return dt; +}; +Date.prototype.getBeforeMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n | 0); + return dt; +}; + +Date.prototype.getAfterMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n * 3); + return dt; +}; +//获得n个季度前的日期 +Date.prototype.getBeforeMulQuarter = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n * 3); + return dt; +}; +//得到本季度的起始月份 +Date.prototype.getQuarterStartMonth = function () { + var quarterStartMonth = 0; + var nowMonth = this.getMonth(); + if (nowMonth < 3) { + quarterStartMonth = 0; + } + if (2 < nowMonth && nowMonth < 6) { + quarterStartMonth = 3; + } + if (5 < nowMonth && nowMonth < 9) { + quarterStartMonth = 6; + } + if (nowMonth > 8) { + quarterStartMonth = 9; + } + return quarterStartMonth; +}; +//获得本季度的起始日期 +Date.prototype.getQuarterStartDate = function () { + return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); +}; +//得到本季度的结束日期 +Date.prototype.getQuarterEndDate = function () { + var quarterEndMonth = this.getQuarterStartMonth() + 2; + return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); +}; +Date.prototype.getAfterMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() + n | 0); + return dt; +}; +Date.prototype.getBeforeMultiMonth = function (n) { + var dt = new Date(this.getTime()); + dt.setMonth(dt.getMonth() - n | 0); + return dt; +}; + /** Checks date and time equality */ Date.prototype.equalsTo = function (date) { return ((this.getFullYear() == date.getFullYear()) &&