2019-04-03 00:25:12 +02:00
|
|
|
import Vue from 'vue'
|
|
|
|
import moment from 'dayjs'
|
|
|
|
import 'dayjs/locale/it'
|
|
|
|
moment.locale('it')
|
|
|
|
|
2019-06-06 23:54:32 +02:00
|
|
|
function short_hour(datetime) {
|
|
|
|
if (datetime.minute() === 0) {
|
|
|
|
return 'h' + datetime.format('HH')
|
|
|
|
} else {
|
|
|
|
return 'h' + datetime.format('HH:mm')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
export default (a) => {
|
2019-05-30 12:12:51 +02:00
|
|
|
Vue.filter('linkify', value => value.replace(/(https?:\/\/[^\s]+)/g, '<a href="$1">$1</a>'))
|
2019-05-30 12:04:14 +02:00
|
|
|
Vue.filter('datetime', value => moment(value).format('ddd, D MMMM HH:mm'))
|
|
|
|
Vue.filter('short_datetime', value => moment(value).format('D/MM HH:mm'))
|
|
|
|
Vue.filter('hour', value => moment(value).format('HH:mm'))
|
2019-06-06 23:54:32 +02:00
|
|
|
Vue.filter('day', value => moment(value).format('dddd, D MMMM'))
|
2019-05-30 12:04:14 +02:00
|
|
|
Vue.filter('month', value => moment(value).format('MMM'))
|
|
|
|
Vue.filter('event_when', event => {
|
2019-06-06 23:54:32 +02:00
|
|
|
const start = moment(event.start_datetime)
|
|
|
|
const end = moment(event.end_datetime)
|
2019-05-30 12:04:14 +02:00
|
|
|
if (event.multidate) {
|
2019-06-06 23:54:32 +02:00
|
|
|
return `${start.format('ddd, D MMMM')} (${short_hour(start)}) - ${end.format('ddd, D MMMM')} (${short_hour(end)})`
|
2019-05-30 12:04:14 +02:00
|
|
|
} else {
|
|
|
|
if (event.end_datetime && event.end_datetime !== event.start_datetime)
|
2019-06-06 23:54:32 +02:00
|
|
|
return `${start.format('ddd, D MMMM')} (${short_hour(start)}-${short_hour(end)}`
|
2019-05-30 12:04:14 +02:00
|
|
|
else
|
2019-06-06 23:54:32 +02:00
|
|
|
return `${start.format('dddd, D MMMM')} (${short_hour(start)})`
|
2019-05-30 12:04:14 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|