gantt-task-react-powern 0.6.42 → 0.6.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ export declare function parseTimeToMinutes(t: string): number;
5
5
  export declare function isHoliday(date: Date, cal: CalendarDefinition): boolean;
6
6
  /** True if the date's weekday is in off_days or is a holiday. */
7
7
  export declare function isOffDay(date: Date, cal: CalendarDefinition): boolean;
8
+ /** Gets the timestamps (Milliseconds - UTC) of all off-days for a calendar between a start and end date*/
9
+ export declare function getOffDays(calendar: CalendarDefinition, start: Date, end: Date): number[];
8
10
  /** True if the date is a regular working day (not off_day, not holiday). */
9
11
  export declare function isWorkingDay(date: Date, cal: CalendarDefinition): boolean;
10
12
  export declare function getShiftsForDay(date: Date, cal: CalendarDefinition): Array<{
package/dist/index.js CHANGED
@@ -381,6 +381,187 @@ var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
381
381
 
382
382
  var styles$1 = {"taskListWrapper":"_3ZbQT","taskListTableRow":"_34SS0","taskListLookAheadRow":"_GzvG4","taskListMilestoneRow":"_3Ykml","taskListCell":"_3lLk3","taskListNameWrapper":"_nI1Xw","taskListExpander":"_2QjE6","taskListExpanderPlaceholder":"_1fnLB","taskListEmptyExpander":"_2TfEi","taskListText":"_2ZvXU"};
383
383
 
384
+ function parseTimeToMinutes(t) {
385
+ var parts = t.split(":").map(Number);
386
+ return parts[0] * 60 + parts[1] + (parts[2] ? parts[2] / 60 : 0);
387
+ }
388
+
389
+ function toDateString(date) {
390
+ var y = date.getFullYear();
391
+ var m = String(date.getMonth() + 1).padStart(2, "0");
392
+ var d = String(date.getDate()).padStart(2, "0");
393
+ return y + "-" + m + "-" + d;
394
+ }
395
+
396
+ function isHoliday(date, cal) {
397
+ if (cal.holidays && cal.holidays.length > 0) {
398
+ return cal.holidays.includes(toDateString(date));
399
+ } else {
400
+ return false;
401
+ }
402
+ }
403
+ function isOffDay(date, cal) {
404
+ if (cal.off_days && cal.off_days.length > 0) {
405
+ return cal.off_days.includes(date.getUTCDay()) || isHoliday(date, cal);
406
+ } else {
407
+ return false;
408
+ }
409
+ }
410
+ function getOffDays(calendar, start, end) {
411
+ var daysOff = [];
412
+ if (!calendar) return daysOff;
413
+ var currentDate = new Date(start);
414
+
415
+ while (currentDate <= end) {
416
+ if (isOffDay(currentDate, calendar)) {
417
+ daysOff.push(currentDate.getTime());
418
+ }
419
+
420
+ currentDate.setDate(currentDate.getDate() + 1);
421
+ }
422
+
423
+ return daysOff;
424
+ }
425
+ var parsedShiftsCache = new WeakMap();
426
+ var offDayCache = new WeakMap();
427
+
428
+ function parsedShifts(cal) {
429
+ var shifts = parsedShiftsCache.get(cal);
430
+
431
+ if (!shifts) {
432
+ var _cal$shifts;
433
+
434
+ shifts = ((_cal$shifts = cal.shifts) != null ? _cal$shifts : []).map(function (_ref) {
435
+ var s = _ref[0],
436
+ e = _ref[1];
437
+ return {
438
+ start: parseTimeToMinutes(s),
439
+ end: parseTimeToMinutes(e)
440
+ };
441
+ });
442
+ parsedShiftsCache.set(cal, shifts);
443
+ }
444
+
445
+ return shifts;
446
+ }
447
+
448
+ function isOffDayCached(date, cal) {
449
+ var perCal = offDayCache.get(cal);
450
+
451
+ if (!perCal) {
452
+ perCal = new Map();
453
+ offDayCache.set(cal, perCal);
454
+ }
455
+
456
+ var key = date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate();
457
+ var off = perCal.get(key);
458
+
459
+ if (off === undefined) {
460
+ off = isOffDay(date, cal);
461
+ perCal.set(key, off);
462
+ }
463
+
464
+ return off;
465
+ }
466
+
467
+ var NO_SHIFTS = [];
468
+ function getShiftsForDay(date, cal) {
469
+ if (!cal.shifts || isOffDayCached(date, cal)) return NO_SHIFTS;
470
+ return parsedShifts(cal);
471
+ }
472
+ function getWorkingIntervals(start, end, cal) {
473
+ if (start >= end) return [];
474
+ var intervals = [];
475
+ var cursor = new Date(start);
476
+ cursor.setHours(0, 0, 0, 0);
477
+
478
+ while (cursor <= end) {
479
+ var shifts = getShiftsForDay(cursor, cal);
480
+
481
+ for (var _iterator = _createForOfIteratorHelperLoose(shifts), _step; !(_step = _iterator()).done;) {
482
+ var shift = _step.value;
483
+ var shiftStart = new Date(cursor);
484
+ shiftStart.setHours(Math.floor(shift.start / 60), Math.floor(shift.start % 60), Math.round(shift.start % 1 * 60), 0);
485
+ var shiftEnd = new Date(cursor);
486
+ shiftEnd.setHours(Math.floor(shift.end / 60), Math.floor(shift.end % 60), Math.round(shift.end % 1 * 60), 0);
487
+ var intervalStart = shiftStart < start ? start : shiftStart;
488
+ var intervalEnd = shiftEnd > end ? end : shiftEnd;
489
+
490
+ if (intervalStart < intervalEnd) {
491
+ intervals.push({
492
+ start: intervalStart,
493
+ end: intervalEnd
494
+ });
495
+ }
496
+ }
497
+
498
+ cursor.setDate(cursor.getDate() + 1);
499
+ }
500
+
501
+ return intervals;
502
+ }
503
+ function snapToWorkingTime(date, cal, direction) {
504
+ var MAX_DAYS = 60;
505
+ var result = new Date(date);
506
+
507
+ for (var attempt = 0; attempt < MAX_DAYS * 24 * 60; attempt++) {
508
+ var dayStart = new Date(result);
509
+ dayStart.setHours(0, 0, 0, 0);
510
+ var shifts = getShiftsForDay(dayStart, cal);
511
+
512
+ if (shifts.length > 0) {
513
+ if (direction === "forward") {
514
+ var currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
515
+
516
+ for (var _iterator2 = _createForOfIteratorHelperLoose(shifts), _step2; !(_step2 = _iterator2()).done;) {
517
+ var shift = _step2.value;
518
+
519
+ if (currentMins <= shift.end) {
520
+ if (currentMins < shift.start) {
521
+ result.setHours(Math.floor(shift.start / 60), Math.round(shift.start % 60), 0, 0);
522
+ }
523
+
524
+ return result;
525
+ }
526
+ }
527
+
528
+ result.setDate(result.getDate() + 1);
529
+ result.setHours(0, 0, 0, 0);
530
+ } else {
531
+ var _currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
532
+
533
+ for (var i = shifts.length - 1; i >= 0; i--) {
534
+ if (_currentMins >= shifts[i].start) {
535
+ if (_currentMins > shifts[i].end) {
536
+ result.setHours(Math.floor(shifts[i].end / 60), Math.round(shifts[i].end % 60), 0, 0);
537
+ }
538
+
539
+ return result;
540
+ }
541
+ }
542
+
543
+ result.setDate(result.getDate() - 1);
544
+ result.setHours(23, 59, 59, 0);
545
+ }
546
+ } else {
547
+ if (direction === "forward") {
548
+ result.setDate(result.getDate() + 1);
549
+ result.setHours(0, 0, 0, 0);
550
+ } else {
551
+ result.setDate(result.getDate() - 1);
552
+ result.setHours(23, 59, 59, 0);
553
+ }
554
+ }
555
+ }
556
+
557
+ return date;
558
+ }
559
+ function getQuarterNumber(date, quarterStart) {
560
+ var month = date.getMonth();
561
+ var offset = (month - quarterStart + 12) % 12;
562
+ return Math.floor(offset / 3) + 1;
563
+ }
564
+
384
565
  var localeDateStringCache = {};
385
566
 
386
567
  var toLocaleDateStringFactory = function toLocaleDateStringFactory(locale) {
@@ -605,7 +786,8 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
605
786
  var actualDuration = function () {
606
787
  if (!t.actualStart || t.actualStart.getTime() === 0) return null;
607
788
  var endRef = t.actualEnd && t.actualEnd.getTime() > 0 ? t.actualEnd : new Date();
608
- return Math.ceil((endRef.getTime() - t.actualStart.getTime()) / (1000 * 60 * 60 * 24));
789
+ var offTimeDays = t.calendar ? getOffDays(t.calendar, t.actualStart, t.actualEnd) : [];
790
+ return Math.ceil((endRef.getTime() - t.actualStart.getTime()) / (1000 * 60 * 60 * 24)) - offTimeDays.length;
609
791
  }();
610
792
 
611
793
  return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
@@ -750,43 +932,6 @@ var Tooltip = function Tooltip(_ref) {
750
932
  type: type
751
933
  }));
752
934
  };
753
-
754
- function getOffTime(task, taskStart, taskEnd, _message) {
755
- var start = taskStart.getTime();
756
- var end = taskEnd.getTime();
757
- var startWeek = Math.floor((start / 86400000 + 4) / 7);
758
- var endWeek = Math.floor((end / 86400000 + 4) / 7);
759
- var offTime = 0;
760
-
761
- if (task.calendar) {
762
- if (task.calendar.off_days && task.calendar.off_days.length) {
763
- for (var d = 0; d < task.calendar.off_days.length || 0; d++) {
764
- for (var w = startWeek; w <= endWeek; w++) {
765
- var dayOfTheWeek = task.calendar.off_days[d];
766
- var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
767
-
768
- if (offDay >= start && offDay <= end) {
769
- offTime += 86400000;
770
- }
771
- }
772
- }
773
- }
774
-
775
- if (task.calendar.holidays && task.calendar.holidays.length) {
776
- for (var h = 0; h < task.calendar.holidays.length || 0; h++) {
777
- var holiday = task.calendar.holidays[h];
778
- var holiday_timestamp = new Date(holiday).getTime();
779
-
780
- if (holiday_timestamp >= start && holiday_timestamp <= end) {
781
- offTime += 86400000;
782
- }
783
- }
784
- }
785
- }
786
-
787
- return offTime;
788
- }
789
-
790
935
  var StandardTooltipContent = function StandardTooltipContent(_ref2) {
791
936
  var _task$plannedDuration, _task$actualDuration;
792
937
 
@@ -798,8 +943,10 @@ var StandardTooltipContent = function StandardTooltipContent(_ref2) {
798
943
  fontSize: fontSize,
799
944
  fontFamily: fontFamily
800
945
  };
801
- var computedPlannedDuration = task.start && task.end && task.end.getTime() - task.start.getTime() > 0 ? Math.max(1, Math.round((task.end.getTime() - task.start.getTime() - getOffTime(task, task.start, task.end)) / (1000 * 60 * 60 * 24))) : (_task$plannedDuration = task.plannedDuration) != null ? _task$plannedDuration : 0;
802
- var computedActualDuration = task.actualStart && task.actualEnd && task.actualEnd.getTime() - task.actualStart.getTime() > 0 ? Math.max(1, Math.round((task.actualEnd.getTime() - task.actualStart.getTime() - getOffTime(task, task.actualStart, task.actualEnd)) / (1000 * 60 * 60 * 24))) : (_task$actualDuration = task.actualDuration) != null ? _task$actualDuration : 0;
946
+ var actualOffTimeDays = task.calendar ? getOffDays(task.calendar, task.actualStart, task.actualEnd) : [];
947
+ var plannedOffTimeDays = task.calendar ? getOffDays(task.calendar, task.start, task.end) : [];
948
+ var computedPlannedDuration = task.start && task.end && task.end.getTime() - task.start.getTime() > 0 ? Math.max(1, Math.round((task.end.getTime() - task.start.getTime()) / (1000 * 60 * 60 * 24)) - plannedOffTimeDays.length) : (_task$plannedDuration = task.plannedDuration) != null ? _task$plannedDuration : 0;
949
+ var computedActualDuration = task.actualStart && task.actualEnd && task.actualEnd.getTime() - task.actualStart.getTime() > 0 ? Math.max(1, Math.round((task.actualEnd.getTime() - task.actualStart.getTime()) / (1000 * 60 * 60 * 24)) - actualOffTimeDays.length) : (_task$actualDuration = task.actualDuration) != null ? _task$actualDuration : 0;
803
950
  if (type == "planned") return React__default.createElement("div", {
804
951
  className: styles$2.tooltipDefaultContainer,
805
952
  style: style
@@ -1258,172 +1405,6 @@ var TaskList = function TaskList(_ref) {
1258
1405
  }, React__default.createElement(TaskListTable, Object.assign({}, tableProps))))));
1259
1406
  };
1260
1407
 
1261
- function parseTimeToMinutes(t) {
1262
- var parts = t.split(":").map(Number);
1263
- return parts[0] * 60 + parts[1] + (parts[2] ? parts[2] / 60 : 0);
1264
- }
1265
-
1266
- function toDateString(date) {
1267
- var y = date.getFullYear();
1268
- var m = String(date.getMonth() + 1).padStart(2, "0");
1269
- var d = String(date.getDate()).padStart(2, "0");
1270
- return y + "-" + m + "-" + d;
1271
- }
1272
-
1273
- function isHoliday(date, cal) {
1274
- if (cal.holidays && cal.holidays.length > 0) {
1275
- return cal.holidays.includes(toDateString(date));
1276
- } else {
1277
- return false;
1278
- }
1279
- }
1280
- function isOffDay(date, cal) {
1281
- if (cal.off_days && cal.off_days.length > 0) {
1282
- return cal.off_days.includes(date.getDay()) || isHoliday(date, cal);
1283
- } else {
1284
- return false;
1285
- }
1286
- }
1287
- var parsedShiftsCache = new WeakMap();
1288
- var offDayCache = new WeakMap();
1289
-
1290
- function parsedShifts(cal) {
1291
- var shifts = parsedShiftsCache.get(cal);
1292
-
1293
- if (!shifts) {
1294
- var _cal$shifts;
1295
-
1296
- shifts = ((_cal$shifts = cal.shifts) != null ? _cal$shifts : []).map(function (_ref) {
1297
- var s = _ref[0],
1298
- e = _ref[1];
1299
- return {
1300
- start: parseTimeToMinutes(s),
1301
- end: parseTimeToMinutes(e)
1302
- };
1303
- });
1304
- parsedShiftsCache.set(cal, shifts);
1305
- }
1306
-
1307
- return shifts;
1308
- }
1309
-
1310
- function isOffDayCached(date, cal) {
1311
- var perCal = offDayCache.get(cal);
1312
-
1313
- if (!perCal) {
1314
- perCal = new Map();
1315
- offDayCache.set(cal, perCal);
1316
- }
1317
-
1318
- var key = date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate();
1319
- var off = perCal.get(key);
1320
-
1321
- if (off === undefined) {
1322
- off = isOffDay(date, cal);
1323
- perCal.set(key, off);
1324
- }
1325
-
1326
- return off;
1327
- }
1328
-
1329
- var NO_SHIFTS = [];
1330
- function getShiftsForDay(date, cal) {
1331
- if (!cal.shifts || isOffDayCached(date, cal)) return NO_SHIFTS;
1332
- return parsedShifts(cal);
1333
- }
1334
- function getWorkingIntervals(start, end, cal) {
1335
- if (start >= end) return [];
1336
- var intervals = [];
1337
- var cursor = new Date(start);
1338
- cursor.setHours(0, 0, 0, 0);
1339
-
1340
- while (cursor <= end) {
1341
- var shifts = getShiftsForDay(cursor, cal);
1342
-
1343
- for (var _iterator = _createForOfIteratorHelperLoose(shifts), _step; !(_step = _iterator()).done;) {
1344
- var shift = _step.value;
1345
- var shiftStart = new Date(cursor);
1346
- shiftStart.setHours(Math.floor(shift.start / 60), Math.floor(shift.start % 60), Math.round(shift.start % 1 * 60), 0);
1347
- var shiftEnd = new Date(cursor);
1348
- shiftEnd.setHours(Math.floor(shift.end / 60), Math.floor(shift.end % 60), Math.round(shift.end % 1 * 60), 0);
1349
- var intervalStart = shiftStart < start ? start : shiftStart;
1350
- var intervalEnd = shiftEnd > end ? end : shiftEnd;
1351
-
1352
- if (intervalStart < intervalEnd) {
1353
- intervals.push({
1354
- start: intervalStart,
1355
- end: intervalEnd
1356
- });
1357
- }
1358
- }
1359
-
1360
- cursor.setDate(cursor.getDate() + 1);
1361
- }
1362
-
1363
- return intervals;
1364
- }
1365
- function snapToWorkingTime(date, cal, direction) {
1366
- var MAX_DAYS = 60;
1367
- var result = new Date(date);
1368
-
1369
- for (var attempt = 0; attempt < MAX_DAYS * 24 * 60; attempt++) {
1370
- var dayStart = new Date(result);
1371
- dayStart.setHours(0, 0, 0, 0);
1372
- var shifts = getShiftsForDay(dayStart, cal);
1373
-
1374
- if (shifts.length > 0) {
1375
- if (direction === "forward") {
1376
- var currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1377
-
1378
- for (var _iterator2 = _createForOfIteratorHelperLoose(shifts), _step2; !(_step2 = _iterator2()).done;) {
1379
- var shift = _step2.value;
1380
-
1381
- if (currentMins <= shift.end) {
1382
- if (currentMins < shift.start) {
1383
- result.setHours(Math.floor(shift.start / 60), Math.round(shift.start % 60), 0, 0);
1384
- }
1385
-
1386
- return result;
1387
- }
1388
- }
1389
-
1390
- result.setDate(result.getDate() + 1);
1391
- result.setHours(0, 0, 0, 0);
1392
- } else {
1393
- var _currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1394
-
1395
- for (var i = shifts.length - 1; i >= 0; i--) {
1396
- if (_currentMins >= shifts[i].start) {
1397
- if (_currentMins > shifts[i].end) {
1398
- result.setHours(Math.floor(shifts[i].end / 60), Math.round(shifts[i].end % 60), 0, 0);
1399
- }
1400
-
1401
- return result;
1402
- }
1403
- }
1404
-
1405
- result.setDate(result.getDate() - 1);
1406
- result.setHours(23, 59, 59, 0);
1407
- }
1408
- } else {
1409
- if (direction === "forward") {
1410
- result.setDate(result.getDate() + 1);
1411
- result.setHours(0, 0, 0, 0);
1412
- } else {
1413
- result.setDate(result.getDate() - 1);
1414
- result.setHours(23, 59, 59, 0);
1415
- }
1416
- }
1417
- }
1418
-
1419
- return date;
1420
- }
1421
- function getQuarterNumber(date, quarterStart) {
1422
- var month = date.getMonth();
1423
- var offset = (month - quarterStart + 12) % 12;
1424
- return Math.floor(offset / 3) + 1;
1425
- }
1426
-
1427
1408
  var styles$5 = {"gridRow":"_2dZTy","gridRowLookAhead":"_2RRca","gridRowLine":"_3rUKi","gridTick":"_RuwuK","gridTickWeekStart":"_1q0EV","gridTickDashed":"_Zh9jh","darkerGridRow":"_2M-tt"};
1428
1409
 
1429
1410
  var GridBody = function GridBody(_ref) {
@@ -3460,7 +3441,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3460
3441
  return s.x2 > s.x1;
3461
3442
  });
3462
3443
  finalTask.actualSegments = actSegs.length > 0 ? actSegs : undefined;
3463
- var actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3444
+ var offTimeDays = finalTask.calendar ? getOffDays(finalTask.calendar, finalTask.actualStart, finalTask.actualEnd) : [];
3445
+ var actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)) - offTimeDays.length);
3464
3446
  finalTask.actualDuration = actDays;
3465
3447
  } else {
3466
3448
  if (ganttEvent.action === "end") {
@@ -3495,13 +3477,10 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3495
3477
  return s.x2 > s.x1;
3496
3478
  });
3497
3479
  finalTask.plannedSegments = planSegs.length > 0 ? planSegs : undefined;
3498
- var totalDaysOff = 0;
3499
- cal.off_days.forEach(function (day) {
3500
- if (day < finalTask.end.getTime() && day > finalTask.start.getTime()) {
3501
- totalDaysOff++;
3502
- }
3503
- });
3504
- var planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)) - totalDaysOff);
3480
+
3481
+ var _offTimeDays = finalTask.calendar ? getOffDays(finalTask.calendar, finalTask.start, finalTask.end) : [];
3482
+
3483
+ var planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)) - _offTimeDays.length);
3505
3484
  finalTask.plannedDuration = planDays;
3506
3485
  }
3507
3486
  } else {
@@ -3600,7 +3579,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3600
3579
  return s.x2 > s.x1;
3601
3580
  });
3602
3581
  newChangedTask.actualSegments = actSegs.length > 0 ? actSegs : undefined;
3603
- var actDays = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3582
+ var offTimeDays = newChangedTask.calendar ? getOffDays(newChangedTask.calendar, newChangedTask.actualStart, newChangedTask.actualEnd) : [];
3583
+ var actDays = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)) - offTimeDays.length);
3604
3584
  newChangedTask.actualDuration = actDays;
3605
3585
  } else {
3606
3586
  if (action === "end") {
@@ -3647,13 +3627,10 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3647
3627
  return s.x2 > s.x1;
3648
3628
  });
3649
3629
  newChangedTask.plannedSegments = planSegs.length > 0 ? planSegs : undefined;
3650
- var totalDaysOff = 0;
3651
- cal.off_days.forEach(function (day) {
3652
- if (day < newChangedTask.end.getTime() && day > newChangedTask.start.getTime()) {
3653
- totalDaysOff++;
3654
- }
3655
- });
3656
- var planDays = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)) - totalDaysOff);
3630
+
3631
+ var _offTimeDays2 = newChangedTask.calendar ? getOffDays(newChangedTask.calendar, newChangedTask.start, newChangedTask.end) : [];
3632
+
3633
+ var planDays = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)) - _offTimeDays2.length);
3657
3634
  newChangedTask.plannedDuration = planDays;
3658
3635
  }
3659
3636
  } else if (action === "move" || action === "end" || action === "start") {
@@ -5079,54 +5056,19 @@ function getCriticalPaths(leafTasks) {
5079
5056
 
5080
5057
  return [[], []];
5081
5058
  }
5082
-
5083
- function getOffTime$1(tIndex, taskMap, start, end) {
5084
- var startWeek = Math.floor((start / 86400000 + 4) / 7);
5085
- var endWeek = Math.floor((end / 86400000 + 4) / 7);
5086
- var offTime = [];
5087
-
5088
- if (taskMap[tIndex].task.calendar) {
5089
- if (taskMap[tIndex].task.calendar.off_days && taskMap[tIndex].task.calendar.off_days.length) {
5090
- for (var d = 0; d < taskMap[tIndex].task.calendar.off_days.length || 0; d++) {
5091
- for (var w = startWeek; w <= endWeek; w++) {
5092
- var dayOfTheWeek = taskMap[tIndex].task.calendar.off_days[d];
5093
- var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
5094
-
5095
- if (offDay >= start && offDay <= end) {
5096
- offTime.push(offDay);
5097
- }
5098
- }
5099
- }
5100
- }
5101
-
5102
- if (taskMap[tIndex].task.calendar.holidays && taskMap[tIndex].task.calendar.holidays.length) {
5103
- for (var h = 0; h < taskMap[tIndex].task.calendar.holidays.length || 0; h++) {
5104
- var holiday = taskMap[tIndex].task.calendar.holidays[h];
5105
- var holiday_timestamp = new Date(holiday).getTime();
5106
-
5107
- if (holiday_timestamp >= start && holiday_timestamp <= end) {
5108
- offTime.push(holiday_timestamp);
5109
- }
5110
- }
5111
- }
5112
- }
5113
-
5114
- return offTime;
5115
- }
5116
-
5117
5059
  function computeCriticalPath(taskID, taskMap) {
5118
5060
  var task = taskMap[taskID].task;
5119
5061
  var dependents = taskMap[taskID].dependents;
5120
5062
  taskMap[taskID].start = task.start.getTime();
5121
5063
  taskMap[taskID].end = task.end.getTime();
5122
5064
  taskMap[taskID].paths = [];
5123
- var parent_off_time = getOffTime$1(taskID, taskMap, taskMap[taskID].start, taskMap[taskID].end);
5065
+ var parent_off_time = getOffDays(taskMap[taskID].calendar, taskMap[taskID].start, taskMap[taskID].end);
5124
5066
 
5125
5067
  for (var j = 0; j < dependents.length; j++) {
5126
5068
  var depStart = taskMap[dependents[j]].task.start.getTime();
5127
5069
  var depEnd = taskMap[dependents[j]].task.end.getTime();
5128
5070
  var depDuration = depEnd - depStart;
5129
- var child_off_time = getOffTime$1(dependents[j], taskMap, depStart, depEnd);
5071
+ var child_off_time = getOffDays(dependents[j].calendar, taskMap[dependents[j]].task.start, taskMap[dependents[j]].task.end);
5130
5072
  var overlap = Math.max(taskMap[taskID].end - depStart, 0);
5131
5073
 
5132
5074
  for (var t = 0; t < parent_off_time.length; t++) {