diff --git a/danfojs-node/src/core/date_range.js b/danfojs-node/src/core/date_range.js index b1805173..9126ff6f 100644 --- a/danfojs-node/src/core/date_range.js +++ b/danfojs-node/src/core/date_range.js @@ -76,7 +76,8 @@ export class date_range { //check if the end year is greater than start year let start_year = start_date.getFullYear(); let end_year = end_date.getFullYear(); - if ((start_year < end_year)){ + if ((start_year <= end_year) && (start_date.getMonth() !== end_date.getMonth())){ + // end_range = start_range + end_range if (this.freq == "M"){ end_range = this.month_end(start_date, end_date); diff --git a/danfojs-node/tests/core/date_range.js b/danfojs-node/tests/core/date_range.js index fc044172..4d869fa7 100644 --- a/danfojs-node/tests/core/date_range.js +++ b/danfojs-node/tests/core/date_range.js @@ -7,15 +7,13 @@ describe("date_range", function(){ // let d = new date_range({"start":'2018-04-24',"end":'2018-04-27'}) // let rslt = [ - // '4/24/2018, 12:00:00 AM', - // '4/25/2018, 12:00:00 AM', - // '4/26/2018, 12:00:00 AM', - // '4/27/2018, 12:00:00 AM' - // ] - + // '4/24/2018, 1:00:00 AM', + // '4/25/2018, 1:00:00 AM', + // '4/26/2018, 1:00:00 AM', + // '4/27/2018, 1:00:00 AM' + // ] // assert.deepEqual(d,rslt) - // }); it("Obtain date between start with end not specified, but period and freq specified", function(){ @@ -90,4 +88,22 @@ describe("date_range", function(){ it("inputing wrong freq offset", function(){ assert.throws(function () { new date_range({ end:'1/1/2018', period:8, freq:"abcm" }); }, Error, 'invalid freq offset abc'); }); + // it("Obtain date between start and end specified with different month", function(){ + + // let d = new date_range({"start":'2018-04-24',"end":'2018-05-27'}) + // let rslt = [ + // '4/24/2018, 1:00:00 AM', + // '4/25/2018, 1:00:00 AM', + // '4/26/2018, 1:00:00 AM', + // '4/27/2018, 1:00:00 AM', + // '4/28/2018, 1:00:00 AM', + // '4/29/2018, 1:00:00 AM', + // '4/30/2018, 1:00:00 AM', + // '5/1/2018, 1:00:00 AM', + // '5/2/2018, 1:00:00 AM', + // '5/3/2018, 1:00:00 AM', + // '5/27/2018, 1:00:00 AM' + // ] + // assert.deepEqual(d,rslt) + // }); });