From 44a94b9417d665e3f34fcf4f99cb476adc46eebe Mon Sep 17 00:00:00 2001 From: jazanne Date: Tue, 20 Dec 2016 17:14:25 -0500 Subject: [PATCH] Fix issue where day ranges were being counted incorrectly, by leveraging moment.js diff() --- src/jquery.daterangepicker.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/jquery.daterangepicker.js b/src/jquery.daterangepicker.js index 26615ff..1bd9f56 100755 --- a/src/jquery.daterangepicker.js +++ b/src/jquery.daterangepicker.js @@ -1863,7 +1863,7 @@ function countDays(start,end) { - return Math.abs( daysFrom1970(start) - daysFrom1970(end) ) + 1; + return moment(start).diff(moment(end), 'd') + 1; } function setDateRange(date1,date2,silent) @@ -2021,7 +2021,7 @@ updateSelectableRange(); bindDayEvents(); } - + function bindDayEvents() { box.find('.day').unbind("click").click(function (evt) { @@ -2184,7 +2184,7 @@ var arrowPrev = '<'; if(opt.customArrowPrevSymbol) arrowPrev = opt.customArrowPrevSymbol; - + var arrowNext = '>'; if(opt.customArrowNextSymbol) arrowNext = opt.customArrowNextSymbol; @@ -2199,11 +2199,11 @@ ' '+ ' '+ ' '+ - ' ' + - (opt.singleDate || !opt.stickyMonths ? '' + arrowNext + '' : '') + + ' ' + + (opt.singleDate || !opt.stickyMonths ? '' + arrowNext + '' : '') + ' '+ ' '+ - ' ' + getWeekHead() + + ' ' + getWeekHead() + ' '+ ' '+ ' '; @@ -2214,8 +2214,8 @@ ''+ ' '+ ' '+ - ' '+ ' '+ @@ -2223,7 +2223,7 @@ ' ' + arrowNext + ''+ ' '+ ' '+ - ' ' + getWeekHead() + + ' ' + getWeekHead() + ' '+ ' '+ '
' + - (!opt.stickyMonths ? '' + arrowPrev + '' : '') + + ' ' + + (!opt.stickyMonths ? '' + arrowPrev + '' : '') + ' '+ '
';