use local instance timezone everywhere #151
This commit is contained in:
@@ -78,8 +78,7 @@ export default {
|
||||
todayEvents () {
|
||||
const start = dayjs(this.value.from).startOf('day').unix()
|
||||
const end = dayjs(this.value.from).endOf('day').unix()
|
||||
const events = this.events.filter(e => e.start_datetime >= start && e.start_datetime <= end)
|
||||
return events
|
||||
return this.events.filter(e => e.start_datetime >= start && e.start_datetime <= end)
|
||||
},
|
||||
attributes () {
|
||||
return attributesFromEvents(this.events, this.tags)
|
||||
@@ -92,10 +91,10 @@ export default {
|
||||
},
|
||||
|
||||
fromHour () {
|
||||
return this.value.from && this.value.fromHour ? dayjs(this.value.from).format('HH:mm') : null
|
||||
return this.value.from && this.value.fromHour ? dayjs.tz(this.value.from).format('HH:mm') : null
|
||||
},
|
||||
dueHour () {
|
||||
return this.value.due && this.value.dueHour ? dayjs(this.value.due).format('HH:mm') : null
|
||||
return this.value.due && this.value.dueHour ? dayjs.tz(this.value.due).format('HH:mm') : null
|
||||
},
|
||||
hourList () {
|
||||
const hourList = []
|
||||
@@ -196,7 +195,7 @@ export default {
|
||||
} else if (what === 'fromHour') {
|
||||
if (value) {
|
||||
const [hour, minute] = value.split(':')
|
||||
const from = dayjs(this.value.from).hour(hour).minute(minute).second(0)
|
||||
const from = dayjs.tz(this.value.from).hour(hour).minute(minute).second(0)
|
||||
this.$emit('input', { ...this.value, from, fromHour: true })
|
||||
} else {
|
||||
this.$emit('input', { ...this.value, fromHour: false })
|
||||
@@ -204,7 +203,7 @@ export default {
|
||||
} else if (what === 'dueHour') {
|
||||
if (value) {
|
||||
const [hour, minute] = value.split(':')
|
||||
const fromHour = dayjs(this.value.from).hour()
|
||||
const fromHour = dayjs.tz(this.value.from).hour()
|
||||
|
||||
// add a day
|
||||
let due = dayjs(this.value.from)
|
||||
@@ -226,20 +225,20 @@ export default {
|
||||
let from = value.start
|
||||
let due = value.end
|
||||
if (this.value.fromHour) {
|
||||
from = dayjs(value.start).hour(dayjs(this.value.from).hour())
|
||||
from = dayjs.tz(value.start).hour(dayjs.tz(this.value.from).hour())
|
||||
}
|
||||
if (this.value.dueHour) {
|
||||
due = dayjs(value.end).hour(dayjs(this.value.due).hour())
|
||||
due = dayjs.tz(value.end).hour(dayjs.tz(this.value.due).hour())
|
||||
}
|
||||
this.$emit('input', { ...this.value, from, due })
|
||||
} else {
|
||||
let from = value
|
||||
let due = this.value.due
|
||||
if (this.value.fromHour) {
|
||||
from = dayjs(value).hour(dayjs(this.value.from).hour())
|
||||
from = dayjs.tz(value).hour(dayjs.tz(this.value.from).hour())
|
||||
}
|
||||
if (this.value.dueHour && this.value.due) {
|
||||
due = dayjs(value).hour(dayjs(this.value.due).hour())
|
||||
due = dayjs.tz(value).hour(dayjs.tz(this.value.due).hour())
|
||||
}
|
||||
this.$emit('input', { ...this.value, from, due })
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export default {
|
||||
validate ({ store }) {
|
||||
return (store.state.auth.loggedIn || store.state.settings.allow_anon_event)
|
||||
},
|
||||
async asyncData ({ params, $axios, error, store }) {
|
||||
async asyncData ({ params, $axios, error }) {
|
||||
if (params.edit) {
|
||||
const data = { event: { place: {}, media: [] } }
|
||||
data.id = params.edit
|
||||
@@ -101,8 +101,8 @@ export default {
|
||||
data.event.place.address = event.place.address || ''
|
||||
data.date = {
|
||||
recurrent: event.recurrent,
|
||||
from: new Date(dayjs.unix(event.start_datetime)),
|
||||
due: new Date(dayjs.unix(event.end_datetime)),
|
||||
from: dayjs.unix(event.start_datetime).toDate(),
|
||||
due: dayjs.unix(event.end_datetime).toDate(),
|
||||
multidate: event.multidate,
|
||||
fromHour: true,
|
||||
dueHour: true
|
||||
@@ -118,8 +118,8 @@ export default {
|
||||
return {}
|
||||
},
|
||||
data () {
|
||||
const month = dayjs().month() + 1
|
||||
const year = dayjs().year()
|
||||
const month = dayjs.tz().month() + 1
|
||||
const year = dayjs.tz().year()
|
||||
return {
|
||||
mdiFileImport, mdiFormatTitle, mdiTagMultiple, mdiCloseCircle,
|
||||
valid: false,
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
<template lang="pug">
|
||||
v-container#home(fluid)
|
||||
v-container#home(fluid)
|
||||
|
||||
//- Announcements
|
||||
#announcements.mx-1.mt-1(v-if='announcements.length')
|
||||
Announcement(v-for='announcement in announcements' :key='`a_${announcement.id}`' :announcement='announcement')
|
||||
//- Announcements
|
||||
#announcements.mx-1.mt-1(v-if='announcements.length')
|
||||
Announcement(v-for='announcement in announcements' :key='`a_${announcement.id}`' :announcement='announcement')
|
||||
|
||||
//- Calendar and search bar
|
||||
v-row.pt-0.pt-sm-2.pl-0.pl-sm-2
|
||||
#calh.col-xl-5.col-lg-5.col-md-7.col-sm-12.col-xs-12.pa-4.pa-sm-3
|
||||
//- this is needed as v-calendar does not support SSR
|
||||
//- https://github.com/nathanreyes/v-calendar/issues/336
|
||||
client-only(placeholder='Calendar unavailable without js')
|
||||
Calendar(@dayclick='dayChange' @monthchange='monthChange' :events='filteredEvents')
|
||||
//- Calendar and search bar
|
||||
v-row.pt-0.pt-sm-2.pl-0.pl-sm-2
|
||||
#calh.col-xl-5.col-lg-5.col-md-7.col-sm-12.col-xs-12.pa-4.pa-sm-3
|
||||
//- this is needed as v-calendar does not support SSR
|
||||
//- https://github.com/nathanreyes/v-calendar/issues/336
|
||||
client-only(placeholder='Calendar unavailable without js')
|
||||
Calendar(@dayclick='dayChange' @monthchange='monthChange' :events='filteredEvents')
|
||||
|
||||
.col.pt-0.pt-md-2
|
||||
Search(:filters='filters' @update='updateFilters')
|
||||
v-chip(v-if='selectedDay' close :close-icon='mdiCloseCircle' @click:close='dayChange()') {{selectedDay}}
|
||||
|
||||
//- Events
|
||||
#events.mb-2.mt-1.pl-1.pl-sm-2
|
||||
Event(:event='event' @destroy='destroy' v-for='(event, idx) in visibleEvents' :lazy='idx>2' :key='event.id' @tagclick='tagClick' @placeclick='placeClick')
|
||||
.col.pt-0.pt-md-2
|
||||
Search(:filters='filters' @update='updateFilters')
|
||||
v-chip(v-if='selectedDay' close :close-icon='mdiCloseCircle' @click:close='dayChange()') {{selectedDay}}
|
||||
|
||||
//- Events
|
||||
#events.mb-2.mt-1.pl-1.pl-sm-2
|
||||
Event(:event='event' @destroy='destroy' v-for='(event, idx) in visibleEvents' :lazy='idx>2' :key='event.id' @tagclick='tagClick' @placeclick='placeClick')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -37,7 +36,7 @@ export default {
|
||||
name: 'Index',
|
||||
components: { Event, Search, Announcement, Calendar },
|
||||
middleware: 'setup',
|
||||
async asyncData ({ params, $api, store }) {
|
||||
async asyncData ({ $api }) {
|
||||
const events = await $api.getEvents({
|
||||
start: dayjs().startOf('month').unix(),
|
||||
end: null,
|
||||
@@ -45,13 +44,13 @@ export default {
|
||||
})
|
||||
return { events }
|
||||
},
|
||||
data ({ $store }) {
|
||||
data () {
|
||||
return {
|
||||
mdiCloseCircle,
|
||||
first: true,
|
||||
isCurrentMonth: true,
|
||||
now: dayjs().unix(),
|
||||
date: dayjs().format('YYYY-MM-DD'),
|
||||
date: dayjs.tz().format('YYYY-MM-DD'),
|
||||
events: [],
|
||||
start: dayjs().startOf('month').unix(),
|
||||
end: null,
|
||||
@@ -113,10 +112,8 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// onIntersect (isIntersecting, eventId) {
|
||||
// this.intersecting[eventId] = isIntersecting
|
||||
// },
|
||||
...mapActions(['setFilters']),
|
||||
|
||||
destroy (id) {
|
||||
this.events = this.events.filter(e => e.id !== id)
|
||||
},
|
||||
@@ -158,16 +155,15 @@ export default {
|
||||
this.selectedDay = null
|
||||
|
||||
// check if current month is selected
|
||||
if (month - 1 === dayjs().month() && year === dayjs().year()) {
|
||||
if (month - 1 === dayjs.tz().month() && year === dayjs.tz().year()) {
|
||||
this.isCurrentMonth = true
|
||||
this.start = dayjs().startOf('month').unix()
|
||||
this.date = dayjs().format('YYYY-MM-DD')
|
||||
this.date = dayjs.tz().format('YYYY-MM-DD')
|
||||
} else {
|
||||
this.isCurrentMonth = false
|
||||
this.date = ''
|
||||
this.start = dayjs().year(year).month(month - 1).startOf('month').unix() // .startOf('week').unix()
|
||||
}
|
||||
// TODO: check if calendar view is double
|
||||
this.end = dayjs().year(year).month(month).endOf('month').unix() // .endOf('week').unix()
|
||||
this.updateEvents()
|
||||
},
|
||||
@@ -175,7 +171,7 @@ export default {
|
||||
this.setFilters(filters)
|
||||
},
|
||||
dayChange (day) {
|
||||
this.selectedDay = day ? dayjs(day).format('YYYY-MM-DD') : null
|
||||
this.selectedDay = day ? dayjs.tz(day).format('YYYY-MM-DD') : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user