diff --git a/pages/add/_edit.vue b/pages/add/_edit.vue index 5b55a7c2..a99cc1ce 100644 --- a/pages/add/_edit.vue +++ b/pages/add/_edit.vue @@ -114,7 +114,7 @@ import { mapActions, mapState, mapGetters } from 'vuex' import uniq from 'lodash/uniq' import map from 'lodash/map' -import moment from 'dayjs' +import moment from 'moment' import List from '@/components/List' import { Message } from 'element-ui' @@ -252,7 +252,7 @@ export default { return this.events.filter(e => !e.multidate ? date_start.isSame(moment.unix(e.start_datetime), 'day') || - date_start.isBefore(moment.unix(e.start_datime)) && date_end.isAfter(moment.unix(e.start_datetime)) + date_start.isBefore(moment.unix(e.start_dateime)) && date_end.isAfter(moment.unix(e.start_datetime)) : date_start.isSame(moment.unix(e.start_datetime), 'day') || date_start.isSame(moment.unix(e.end_datetime)) || date_start.isAfter(moment.unix(e.start_datetime)) && date_start.isBefore(moment.unix(e.end_datetime))) } else if (this.event.type === 'recurrent') { @@ -268,6 +268,7 @@ export default { } }, ...mapGetters(['filteredEvents']), + // TOFIX attributes () { let attributes = [] attributes.push({ key: 'today', dates: new Date(), highlight: { color: 'yellow' } }) @@ -389,8 +390,8 @@ export default { formData.append('place_address', this.event.place.address) formData.append('description', this.event.description) formData.append('multidate', this.event.type === 'multidate') - formData.append('start_datetime', start_datetime.unix()) - formData.append('end_datetime', end_datetime.unix()) + formData.append('start_datetime', start_datetime.utc(true).unix()) + formData.append('end_datetime', end_datetime.utc(true).unix()) if (this.edit) { formData.append('id', this.event.id) diff --git a/plugins/filters.js b/plugins/filters.js index f48c9162..3804e7e1 100644 --- a/plugins/filters.js +++ b/plugins/filters.js @@ -1,29 +1,30 @@ import Vue from 'vue' -import moment from 'dayjs' -import 'dayjs/locale/it' -import 'dayjs/locale/es' +import moment from 'moment' +// import 'dayjs/locale/it' +// import 'dayjs/locale/es' export default ({ app, store }) => { // replace links with anchors // TODO: remove fb tracking id Vue.filter('linkify', value => value.replace(/(https?:\/\/[^\s]+)/g, '$1')) Vue.filter('url2host', url => url.match(/^https?:\/\/(.[^/:]+)/i)[1]) - Vue.filter('datetime', value => moment(value).locale(store.state.locale).format('ddd, D MMMM HH:mm')) + Vue.filter('datetime', value => moment(value).utc(false).locale(store.state.locale).format('ddd, D MMMM HH:mm')) // Vue.filter('short_datetime', value => moment(value).locale(store.state.locale).format('D/MM HH:mm')) // Vue.filter('hour', value => moment(value).locale(store.state.locale).format('HH:mm')) // shown in mobile homepage - Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMM')) + Vue.filter('day', value => moment.unix(value).utc(false).locale(store.state.locale).format('dddd, D MMM')) // Vue.filter('month', value => moment(value).locale(store.state.locale).format('MMM')) // format event start/end datetime based on page Vue.filter('when', (event, where) => { moment.locale(store.state.locale) - // {start,end}_datetime are unix timestamp - const start = moment.unix(event.start_datetime) - const end = moment.unix(event.end_datetime) - + // show local time relative to event's place + // (not where in the worlds I'm looking at the page from) + const start = moment.unix(event.start_datetime).utc(false) + const end = moment.unix(event.end_datetime).utc(false) + const normal = `${start.format('dddd, D MMMM (HH:mm-')}${end.format('HH:mm)')}` // recurrent event diff --git a/server/api/controller/event.js b/server/api/controller/event.js index 01500ed1..4c143369 100644 --- a/server/api/controller/event.js +++ b/server/api/controller/event.js @@ -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 diff --git a/server/api/controller/export.js b/server/api/controller/export.js index 8ff1e823..d7ad6f55 100644 --- a/server/api/controller/export.js +++ b/server/api/controller/export.js @@ -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 { diff --git a/server/api/models/event.js b/server/api/models/event.js index eb0b572e..d5fd724e 100644 --- a/server/api/models/event.js +++ b/server/api/models/event.js @@ -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 => ``).join(' ') const content = `${this.title}
📍${this.place.name}
- ⏰ ${moment.unix(this.start_datetime).format('dddd, D MMMM (HH:mm)')}

+ ⏰ ${moment.unix(this.start_datetime).utc(false).format('dddd, D MMMM (HH:mm)')}

${this.description.length > 200 ? this.description.substr(0, 200) + '...' : this.description}
${tags}
` @@ -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 - } } } diff --git a/views/feed/rss.pug b/views/feed/rss.pug index 67f46d5f..52d47486 100644 --- a/views/feed/rss.pug +++ b/views/feed/rss.pug @@ -7,13 +7,13 @@ rss(version='2.0') language #{config.locale} each event in events item - title [#{moment.unix(event.start_datetime).format("YY-MM-DD")}] #{event.title} @#{event.place.name} + title [#{moment.unix(event.start_datetime).utc(false).format("YY-MM-DD")}] #{event.title} @#{event.place.name} link #{config.baseurl}/event/#{event.id} description | #{event.title} | #{event.place.name} - #{event.place.address} - | (#{moment.unix(event.start_datetime).format("dddd, D MMMM HH:mm")})
+ | (#{moment.unix(event.start_datetime).utc(false).format("dddd, D MMMM HH:mm")})
if (event.image_path) | |
!{event.description}