From 7b1679a30d61cefef27dca0f33904fd3b66f9c59 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 9 May 2017 11:19:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=88=E4=BB=BD=E5=81=8F=E7=A7=BB=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/core.js | 14 ++++++++++++++ docs/core.js | 14 ++++++++++++++ src/core/proto/date.js | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/bi/core.js b/bi/core.js index d9254f202..d36ff77a3 100644 --- a/bi/core.js +++ b/bi/core.js @@ -6354,6 +6354,20 @@ Date.prototype.getQuarterStartMonth = function () { } return quarterStartMonth; }; + +//指定日期n个月之前或之后的日期 +Date.prototype.getOffsetMonth = function (n) { + var dt = new Date(this.getTime()); + var day = dt.getDate(); + var monthDay = new Date(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays(); + if(day > monthDay){ + day = monthDay; + } + dt.setDate(day); + dt.setMonth(dt.getMonth() + parseInt(n)); + return dt; +}; + //获得本季度的起始日期 Date.prototype.getQuarterStartDate = function () { return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1); diff --git a/docs/core.js b/docs/core.js index ca61c1ec3..dcd1f9474 100644 --- a/docs/core.js +++ b/docs/core.js @@ -23834,6 +23834,20 @@ Date.prototype.getQuarterStartMonth = function () { } return quarterStartMonth; }; + +//指定日期n个月之前或之后的日期 +Date.prototype.getOffsetMonth = function (n) { + var dt = new Date(this.getTime()); + var day = dt.getDate(); + var monthDay = new Date(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays(); + if(day > monthDay){ + day = monthDay; + } + dt.setDate(day); + dt.setMonth(dt.getMonth() + parseInt(n)); + return dt; +}; + //获得本季度的起始日期 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 1ae8b5959..e3146708b 100644 --- a/src/core/proto/date.js +++ b/src/core/proto/date.js @@ -182,6 +182,20 @@ Date.prototype.getQuarterStartMonth = function () { } return quarterStartMonth; }; + +//指定日期n个月之前或之后的日期 +Date.prototype.getOffsetMonth = function (n) { + var dt = new Date(this.getTime()); + var day = dt.getDate(); + var monthDay = new Date(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays(); + if(day > monthDay){ + day = monthDay; + } + dt.setDate(day); + dt.setMonth(dt.getMonth() + parseInt(n)); + return dt; +}; + //获得本季度的起始日期 Date.prototype.getQuarterStartDate = function () { return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1);