Skip to content

Commit c483273

Browse files
committed
pushing fixes for e2e 2 and 4, making checks on input string in parseDuration function
1 parent 067af12 commit c483273

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/mermaid/src/diagrams/gantt/ganttDb.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const getTodayMarker = function () {
9393
};
9494

9595
export const setDateFormat = function (txt) {
96-
dateFormat = txt;
96+
dateFormat = txt.trim().replace(/^:/, '').trim();
9797
};
9898

9999
export const enableInclusiveEndDates = function () {
@@ -351,8 +351,12 @@ const getStartDate = function (prevTime, dateFormat, str) {
351351
* @returns {[value: number, unit: dayjs.ManipulateType]} Arguments to pass to `dayjs.add()`
352352
*/
353353
const parseDuration = function (str) {
354+
const trimmed = str.trim();
355+
if (trimmed === '0' || trimmed === '') {
356+
return [0, 'ms'];
357+
}
354358
// cspell:disable-next-line
355-
const statement = /^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/.exec(str.trim());
359+
const statement = /^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/.exec(trimmed);
356360
if (statement !== null) {
357361
return [Number.parseFloat(statement[1]), statement[2]];
358362
}

0 commit comments

Comments
 (0)