recurrent 1w/2w working
This commit is contained in:
17
package.json
17
package.json
@@ -42,7 +42,7 @@
|
||||
"bcryptjs": "^2.4.3",
|
||||
"body-parser": "^1.18.3",
|
||||
"bootstrap": "^4.3.1",
|
||||
"config": "^3.1.0",
|
||||
"config": "^3.2.0",
|
||||
"consola": "^2.9.0",
|
||||
"cookie-parser": "^1.4.4",
|
||||
"cors": "^2.8.5",
|
||||
@@ -53,34 +53,35 @@
|
||||
"express": "^4.17.1",
|
||||
"express-jwt": "^5.3.1",
|
||||
"ics": "^2.15.1",
|
||||
"inquirer": "^6.3.1",
|
||||
"inquirer": "^6.5.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"less": "^3.9.0",
|
||||
"lodash": "^4.17.14",
|
||||
"mastodon-api": "lesion/mastodon-api",
|
||||
"morgan": "^1.9.1",
|
||||
"multer": "^1.4.1",
|
||||
"multer": "^1.4.2",
|
||||
"nuxt": "^2.8.1",
|
||||
"nuxt-i18n": "^5.12.4",
|
||||
"pg": "^7.11.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"sequelize": "^5.9.4",
|
||||
"sequelize": "^5.10.1",
|
||||
"sequelize-cli": "^5.4.0",
|
||||
"sharp": "^0.22.0",
|
||||
"sqlite3": "^4.0.8",
|
||||
"v-calendar": "^1.0.0-beta.14",
|
||||
"vue-awesome": "^3.5.3",
|
||||
"vue-clipboard2": "^0.3.0",
|
||||
"yargs": "^13.2.4"
|
||||
"yargs": "^13.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxtjs/eslint-config": "^1.0.1",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^6.0.1",
|
||||
"eslint-config-prettier": "^6.0.0",
|
||||
"eslint-config-standard": ">=12.0.0",
|
||||
"eslint-config-standard": ">=13.0.1",
|
||||
"eslint-loader": "^2.2.1",
|
||||
"eslint-plugin-import": ">=2.17.3",
|
||||
"eslint-plugin-jest": ">=22.7.2",
|
||||
"eslint-plugin-jest": ">=22.11.1",
|
||||
"eslint-plugin-node": ">=9.1.0",
|
||||
"eslint-plugin-nuxt": ">=0.4.2",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
@@ -91,6 +92,6 @@
|
||||
"nodemon": "^1.19.1",
|
||||
"prettier": "^1.17.1",
|
||||
"pug-plain-loader": "^1.0.0",
|
||||
"webpack-cli": "^3.3.2"
|
||||
"webpack-cli": "^3.3.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,8 @@ const eventController = {
|
||||
const events = []
|
||||
const recurrent = JSON.parse(e.recurrent)
|
||||
if (!recurrent.frequency) return false
|
||||
const cursor = moment(start)
|
||||
|
||||
let cursor = moment(start).startOf('isoWeek')
|
||||
const start_date = moment(e.start_datetime)
|
||||
const duration = moment(e.end_datetime).diff(start_date, 's')
|
||||
const frequency = recurrent.frequency
|
||||
@@ -236,14 +237,10 @@ const eventController = {
|
||||
|
||||
// each week or 2 (search for the first specified day)
|
||||
if (frequency === '1w' || frequency === '2w') {
|
||||
while(true) {
|
||||
const found = days.indexOf(cursor.day())
|
||||
if (found!==-1) break
|
||||
cursor.add(1, 'day')
|
||||
}
|
||||
cursor.add(days[0]-1, 'day')
|
||||
if (frequency === '2w') {
|
||||
const nWeeks = cursor.diff(start_datetime, 'w')%2
|
||||
if (nWeeks) cursor.add(1, 'week')
|
||||
const nWeeks = cursor.diff(e.start_datetime, 'w')%2
|
||||
if (!nWeeks) cursor.add(1, 'week')
|
||||
}
|
||||
toAdd.n = Number(frequency[0])
|
||||
toAdd.unit = 'week';
|
||||
@@ -260,11 +257,16 @@ const eventController = {
|
||||
|
||||
// add event at specified frequency
|
||||
while (true) {
|
||||
if (dueTo && cursor.isAfter(dueTo)) break
|
||||
e.start_datetime = cursor.unix()*1000
|
||||
e.end_datetime = e.start_datetime+(duration*1000)// cursor.clone().hour(end_datetime.hour()).minute(end_datetime.minute()).unix()*1000
|
||||
events.push( Object.assign({}, e) )
|
||||
cursor.add(toAdd.n, toAdd.unit)
|
||||
let first_event_of_week = cursor.clone()
|
||||
days.forEach(d => {
|
||||
cursor.day(d-1)
|
||||
if (cursor.isAfter(dueTo)) return
|
||||
e.start_datetime = cursor.unix()*1000
|
||||
e.end_datetime = e.start_datetime+(duration*1000)// cursor.clone().hour(end_datetime.hour()).minute(end_datetime.minute()).unix()*1000
|
||||
events.push( Object.assign({}, e) )
|
||||
})
|
||||
if (cursor.isAfter(dueTo)) break
|
||||
cursor = first_event_of_week.add(toAdd.n, toAdd.unit)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user