Merge pull request #6734 from mermaid-js/6730-gantt-excludes-datetime-format

6730: Fix excluded dates ignored in YYYY-MM-DD HH:mm:ss date format in gantt diagram
This commit is contained in:
Knut Sveidqvist
2025-08-08 09:33:56 +00:00
committed by GitHub
4 changed files with 57 additions and 12 deletions

View File

@@ -167,7 +167,10 @@ export const getTasks = function () {
};
export const isInvalidDate = function (date, dateFormat, excludes, includes) {
if (includes.includes(date.format(dateFormat.trim()))) {
const formattedDate = date.format(dateFormat.trim());
const dateOnly = date.format('YYYY-MM-DD');
if (includes.includes(formattedDate) || includes.includes(dateOnly)) {
return false;
}
if (
@@ -180,7 +183,7 @@ export const isInvalidDate = function (date, dateFormat, excludes, includes) {
if (excludes.includes(date.format('dddd').toLowerCase())) {
return true;
}
return excludes.includes(date.format(dateFormat.trim()));
return excludes.includes(formattedDate) || excludes.includes(dateOnly);
};
export const setWeekday = function (txt) {

View File

@@ -581,17 +581,11 @@ export const draw = function (text, id, version, diagObj) {
rectangles
.append('rect')
.attr('id', function (d) {
return 'exclude-' + d.start.format('YYYY-MM-DD');
})
.attr('x', function (d) {
return timeScale(d.start) + theSidePad;
})
.attr('id', (d) => 'exclude-' + d.start.format('YYYY-MM-DD'))
.attr('x', (d) => timeScale(d.start.startOf('day')) + theSidePad)
.attr('y', conf.gridLineStartPadding)
.attr('width', function (d) {
const renderEnd = d.end.add(1, 'day');
return timeScale(renderEnd) - timeScale(d.start);
})
.attr('width', (d) => timeScale(d.end.endOf('day')) - timeScale(d.start.startOf('day')))
.attr('height', h - theTopPad - conf.gridLineStartPadding)
.attr('transform-origin', function (d, i) {
return (