mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 17:29:54 +02:00
Standard
This commit is contained in:
@@ -64,13 +64,19 @@ export const getTasks = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getNextValidDate = function (date, dateFormat, excludes) {
|
const getNextValidDate = function (date, dateFormat, excludes) {
|
||||||
const excludeWeekends = excludes.indexOf('weekend') >= 0 || excludes.indexOf('weekends') >= 0;
|
const excludeWeekends = excludes.indexOf('weekend') >= 0 || excludes.indexOf('weekends') >= 0
|
||||||
const trimmedDateFormat = dateFormat.trim()
|
const trimmedDateFormat = dateFormat.trim()
|
||||||
let mDate = moment.isMoment(date) ? date : (moment.isDate(date) ? moment(date) : moment(date, dateFormat, true));
|
let mDate = moment.isMoment(date) ? date : (moment.isDate(date) ? moment(date) : moment(date, dateFormat, true))
|
||||||
while ((excludeWeekends && mDate.isoWeekday() >= 6) || (excludes.indexOf(mDate.format(trimmedDateFormat)) >= 0)) {
|
|
||||||
|
const isInvalidDate = function (d) {
|
||||||
|
return (excludeWeekends && d.isoWeekday() >= 6) || (excludes.indexOf(d.format(trimmedDateFormat)) >= 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
while (isInvalidDate(mDate)) {
|
||||||
mDate = mDate.add(1, 'd')
|
mDate = mDate.add(1, 'd')
|
||||||
}
|
}
|
||||||
return mDate.toDate();
|
|
||||||
|
return mDate.toDate()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getStartDate = function (prevTime, dateFormat, excludes, str) {
|
const getStartDate = function (prevTime, dateFormat, excludes, str) {
|
||||||
@@ -86,15 +92,15 @@ const getStartDate = function (prevTime, dateFormat, excludes, str) {
|
|||||||
if (typeof task === 'undefined') {
|
if (typeof task === 'undefined') {
|
||||||
const dt = new Date()
|
const dt = new Date()
|
||||||
dt.setHours(0, 0, 0, 0)
|
dt.setHours(0, 0, 0, 0)
|
||||||
//return getNextValidDate(dt, dateFormat, excludes)
|
// return getNextValidDate(dt, dateFormat, excludes)
|
||||||
return dt
|
return dt
|
||||||
}
|
}
|
||||||
//return getNextValidDate(task.endTime, dateFormat, excludes)
|
// return getNextValidDate(task.endTime, dateFormat, excludes)
|
||||||
return task.endTime
|
return task.endTime
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for actual date set
|
// Check for actual date set
|
||||||
let mDate = moment(str, dateFormat.trim(), true);
|
let mDate = moment(str, dateFormat.trim(), true)
|
||||||
if (mDate.isValid()) {
|
if (mDate.isValid()) {
|
||||||
return getNextValidDate(mDate, dateFormat, excludes)
|
return getNextValidDate(mDate, dateFormat, excludes)
|
||||||
} else {
|
} else {
|
||||||
@@ -110,9 +116,9 @@ const getEndDate = function (prevTime, dateFormat, excludes, str) {
|
|||||||
str = str.trim()
|
str = str.trim()
|
||||||
|
|
||||||
// Check for actual date
|
// Check for actual date
|
||||||
let mDate = moment(str, dateFormat.trim(), true);
|
let mDate = moment(str, dateFormat.trim(), true)
|
||||||
if (mDate.isValid()) {
|
if (mDate.isValid()) {
|
||||||
//return getNextValidDate(mDate, dateFormat, excludes)
|
// return getNextValidDate(mDate, dateFormat, excludes)
|
||||||
return mDate.toDate()
|
return mDate.toDate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user