mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 23:39:50 +02:00
Codeclimate - Complexity
This commit is contained in:
@@ -63,19 +63,17 @@ export const getTasks = function () {
|
|||||||
return tasks
|
return tasks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isInvalidDate = function (date, dateFormat, excludes) {
|
||||||
|
if (date.isoWeekday() >= 6 && excludes.indexOf('weekends') >= 0)
|
||||||
|
return true;
|
||||||
|
return excludes.indexOf(date.format(dateFormat.trim())) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
const getNextValidDate = function (date, dateFormat, excludes) {
|
const getNextValidDate = function (date, dateFormat, excludes) {
|
||||||
const excludeWeekends = excludes.indexOf('weekend') >= 0 || excludes.indexOf('weekends') >= 0
|
let mDate = moment(date, dateFormat, true)
|
||||||
const trimmedDateFormat = dateFormat.trim()
|
while (isInvalidDate(mDate, dateFormat, excludes)) {
|
||||||
let mDate = moment.isMoment(date) ? date : (moment.isDate(date) ? moment(date) : moment(date, dateFormat, true))
|
|
||||||
|
|
||||||
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user