diff options
Diffstat (limited to 'app/assets/javascripts/lib/utils/datetime_utility.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/datetime_utility.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js index 996692bacb3..794391da103 100644 --- a/app/assets/javascripts/lib/utils/datetime_utility.js +++ b/app/assets/javascripts/lib/utils/datetime_utility.js @@ -392,15 +392,21 @@ export const getTimeframeWindowFrom = (initialStartDate, length) => { * @param {Date} date * @param {Array} quarter */ -export const dayInQuarter = (date, quarter) => - quarter.reduce((acc, month) => { - if (date.getMonth() > month.getMonth()) { +export const dayInQuarter = (date, quarter) => { + const dateValues = { + date: date.getDate(), + month: date.getMonth(), + }; + + return quarter.reduce((acc, month) => { + if (dateValues.month > month.getMonth()) { return acc + totalDaysInMonth(month); - } else if (date.getMonth() === month.getMonth()) { - return acc + date.getDate(); + } else if (dateValues.month === month.getMonth()) { + return acc + dateValues.date; } return acc + 0; }, 0); +}; window.gl = window.gl || {}; window.gl.utils = { |