From 5bfddcc444c6cb8464afa58cb0973a7f5e5e8452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Poffo?= Date: Thu, 7 Feb 2019 11:27:01 -0200 Subject: [PATCH] Complexity --- src/diagrams/gantt/ganttDb.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/diagrams/gantt/ganttDb.js b/src/diagrams/gantt/ganttDb.js index a15bd223e..8c70d9c70 100644 --- a/src/diagrams/gantt/ganttDb.js +++ b/src/diagrams/gantt/ganttDb.js @@ -74,17 +74,20 @@ const isInvalidDate = function (date, dateFormat, excludes) { } const fixTaskDates = function (task, dateFormat, excludes) { - if (excludes.length && !task.manualEndTime) { - let startTime = moment(task.startTime).add(1, 'd') - let endTime = moment(task.endTime) - while (startTime.date() <= endTime.date()) { - if (isInvalidDate(startTime, dateFormat, excludes)) { - endTime.add(1, 'd') - } - startTime.add(1, 'd') + if (! excludes.length || task.manualEndTime) return; + + let startTime = moment(task.startTime) + startTime.add(1, 'd') + let endTime = moment(task.endTime) + + while (startTime.date() <= endTime.date()) { + if (isInvalidDate(startTime, dateFormat, excludes)) { + endTime.add(1, 'd') } - task.endTime = endTime.toDate() + startTime.add(1, 'd') } + + task.endTime = endTime.toDate() } const getStartDate = function (prevTime, dateFormat, str) {