test and fix some recurrent events
This commit is contained in:
@@ -690,7 +690,7 @@ const eventController = {
|
||||
const parentStartDatetime = DateTime.fromSeconds(e.start_datetime)
|
||||
|
||||
// cursor is when start to count
|
||||
// sets it to
|
||||
// in case parent is in past, start to calculate from now
|
||||
let cursor = parentStartDatetime > startAt ? parentStartDatetime : startAt
|
||||
startAt = cursor
|
||||
|
||||
@@ -711,6 +711,8 @@ const eventController = {
|
||||
cursor = cursor.plus({ days: 7 * Number(frequency[0]) })
|
||||
}
|
||||
} else if (frequency === '1m') {
|
||||
|
||||
// day n.X each month
|
||||
if (type === 'ordinal') {
|
||||
cursor = cursor.set({ day: parentStartDatetime.day })
|
||||
|
||||
@@ -718,10 +720,10 @@ const eventController = {
|
||||
cursor = cursor.plus({ months: 1 })
|
||||
}
|
||||
} else { // weekday
|
||||
// get weekday
|
||||
|
||||
// get recurrent freq details
|
||||
cursor = helpers.getWeekdayN(cursor, type, parentStartDatetime.weekday)
|
||||
if (cursor< startAt) {
|
||||
if (cursor < startAt) {
|
||||
cursor = cursor.plus({ months: 1 })
|
||||
cursor = helpers.getWeekdayN(cursor, type, parentStartDatetime.weekday)
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ module.exports = {
|
||||
} else {
|
||||
cursor = date.startOf('month')
|
||||
// cursor = cursor.add(cursor.day <= date.day ? n - 1 : n, 'week')
|
||||
cursor = cursor.plus({ days: cursor.weekday <= date.weekday ? (n-1) * 7 : n * 7})
|
||||
cursor = cursor.plus({ weeks: cursor.weekday <= weekday ? n-1 : n })
|
||||
cursor = cursor.set({ weekday })
|
||||
}
|
||||
cursor = cursor.set({ hour: date.hour, minute: date.minute, second: 0 })
|
||||
@@ -293,5 +293,10 @@ module.exports = {
|
||||
} else {
|
||||
res.sendStatus(403)
|
||||
}
|
||||
},
|
||||
|
||||
queryParamToBool (value) {
|
||||
return ((value+'').toLowerCase() === 'true')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user