[fix] ~ #38
This commit is contained in:
@@ -188,11 +188,13 @@ const eventController = {
|
||||
.month(req.params.month)
|
||||
.startOf('month')
|
||||
.startOf('week')
|
||||
.utc(false)
|
||||
|
||||
let end = moment()
|
||||
.year(req.params.year)
|
||||
.month(req.params.month)
|
||||
.endOf('month')
|
||||
.utc(false)
|
||||
|
||||
const shownDays = end.diff(start, 'days')
|
||||
if (shownDays <= 35) { end = end.add(1, 'week') }
|
||||
@@ -231,7 +233,7 @@ const eventController = {
|
||||
if (!recurrent.frequency) { return false }
|
||||
|
||||
let cursor = moment(start).startOf('week')
|
||||
const start_date = moment.unix(e.start_datetime)
|
||||
const start_date = moment.unix(e.start_datetime).utc(false)
|
||||
const duration = moment.unix(e.end_datetime).diff(start_date, 's')
|
||||
const frequency = recurrent.frequency
|
||||
const days = recurrent.days
|
||||
@@ -239,7 +241,6 @@ const eventController = {
|
||||
|
||||
// default frequency is '1d' => each day
|
||||
const toAdd = { n: 1, unit: 'day' }
|
||||
cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
|
||||
|
||||
// each week or 2 (search for the first specified day)
|
||||
if (frequency === '1w' || frequency === '2w') {
|
||||
@@ -253,6 +254,8 @@ const eventController = {
|
||||
// cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
|
||||
}
|
||||
|
||||
cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
|
||||
|
||||
// each month or 2
|
||||
if (frequency === '1m' || frequency === '2m') {
|
||||
// find first match
|
||||
@@ -275,12 +278,13 @@ const eventController = {
|
||||
cursor.day(d - 1)
|
||||
}
|
||||
if (cursor.isAfter(dueTo) || cursor.isBefore(start)) { return }
|
||||
e.start_datetime = cursor.unix()
|
||||
e.start_datetime = cursor.utc(true).unix()
|
||||
e.end_datetime = e.start_datetime + duration
|
||||
events.push(Object.assign({}, e))
|
||||
})
|
||||
if (cursor.isAfter(dueTo)) { break }
|
||||
cursor = first_event_of_week.add(toAdd.n, toAdd.unit)
|
||||
cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
|
||||
}
|
||||
|
||||
return events
|
||||
|
||||
@@ -51,8 +51,8 @@ const exportController = {
|
||||
|
||||
ics (res, events) {
|
||||
const eventsMap = events.map(e => {
|
||||
const tmpStart = moment.unix(e.start_datetime)
|
||||
const tmpEnd = moment.unix(e.end_datetime)
|
||||
const tmpStart = moment.unix(e.start_datetime).utc(false)
|
||||
const tmpEnd = moment.unix(e.end_datetime).utc(false)
|
||||
const start = [tmpStart.year(), tmpStart.month() + 1, tmpStart.date(), tmpStart.hour(), tmpStart.minute()]
|
||||
const end = [tmpEnd.year(), tmpEnd.month() + 1, tmpEnd.date(), tmpEnd.hour(), tmpEnd.minute()]
|
||||
return {
|
||||
|
||||
@@ -36,13 +36,12 @@ module.exports = (sequelize, DataTypes) => {
|
||||
event.hasMany(models.comment)
|
||||
}
|
||||
|
||||
//
|
||||
event.prototype.toAP = function (username, follower = []) {
|
||||
const tags = this.tags && this.tags.map(t => `<a href='/tags/${t.tag}' class='mention hashtag' rel='tag'>#${t.tag}</a>`).join(' ')
|
||||
|
||||
const content = `<a href='${config.baseurl}/event/${this.id}'>${this.title}</a><br/>
|
||||
📍${this.place.name}<br/>
|
||||
⏰ ${moment.unix(this.start_datetime).format('dddd, D MMMM (HH:mm)')}<br/><br/>
|
||||
⏰ ${moment.unix(this.start_datetime).utc(false).format('dddd, D MMMM (HH:mm)')}<br/><br/>
|
||||
${this.description.length > 200 ? this.description.substr(0, 200) + '...' : this.description}<br/>
|
||||
${tags} <br/>`
|
||||
|
||||
@@ -74,12 +73,6 @@ module.exports = (sequelize, DataTypes) => {
|
||||
content,
|
||||
summary: null,
|
||||
sensitive: false,
|
||||
startTime: moment.unix(this.start_datetime),
|
||||
location: {
|
||||
type: 'Place',
|
||||
name: this.place.name,
|
||||
address: this.place.address
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user