From 63096a5c269cfad4a02e599759be9dbc9bfbd109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20W=C3=BCrtz?= Date: Sat, 6 Jul 2019 12:27:28 -0300 Subject: [PATCH] feat(ganttDb.js): add 1 day to end dates if inclusive is set to true This will essentially keep all old behavior the same while still allowing users to specify if they want inclusive end dates --- src/diagrams/gantt/ganttDb.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/diagrams/gantt/ganttDb.js b/src/diagrams/gantt/ganttDb.js index 41a150430..006775acf 100644 --- a/src/diagrams/gantt/ganttDb.js +++ b/src/diagrams/gantt/ganttDb.js @@ -11,6 +11,7 @@ let tasks = [] let currentSection = '' const tags = ['active', 'done', 'crit', 'milestone'] let funs = [] +let inclusiveEndDates = false export const clear = function () { sections = [] @@ -25,6 +26,7 @@ export const clear = function () { dateFormat = '' axisFormat = '' excludes = [] + inclusiveEndDates = false } export const setAxisFormat = function (txt) { @@ -35,8 +37,9 @@ export const getAxisFormat = function () { return axisFormat } -export const setDateFormat = function (txt) { +export const setDateFormat = function (txt, inclusive) { dateFormat = txt + inclusiveEndDates = inclusive || false // make sure it's not undefined } export const getDateFormat = function () { @@ -149,12 +152,16 @@ const getStartDate = function (prevTime, dateFormat, str) { return new Date() } -const getEndDate = function (prevTime, dateFormat, str) { +const getEndDate = function (prevTime, dateFormat, str, inclusive) { + inclusive = inclusive || false str = str.trim() // Check for actual date let mDate = moment(str, dateFormat.trim(), true) if (mDate.isValid()) { + if (inclusive) { + mDate.add(1, 'd') + } return mDate.toDate() }