This commit is contained in:
lesion
2019-06-06 23:54:32 +02:00
parent 745b9247c9
commit 3ca818f016
66 changed files with 989 additions and 532 deletions

View File

@@ -3,21 +3,31 @@ import moment from 'dayjs'
import 'dayjs/locale/it'
moment.locale('it')
function short_hour(datetime) {
if (datetime.minute() === 0) {
return 'h' + datetime.format('HH')
} else {
return 'h' + datetime.format('HH:mm')
}
}
export default (a) => {
Vue.filter('linkify', value => value.replace(/(https?:\/\/[^\s]+)/g, '<a href="$1">$1</a>'))
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'))
Vue.filter('day', value => moment(value).format('ddd, D MMM'))
Vue.filter('day', value => moment(value).format('dddd, D MMMM'))
Vue.filter('month', value => moment(value).format('MMM'))
Vue.filter('event_when', event => {
const start = moment(event.start_datetime)
const end = moment(event.end_datetime)
if (event.multidate) {
return moment(event.start_datetime).format('ddd, D MMMM HH:mm') + ' - ' + moment(event.end_datetime).format('ddd, D MMMM')
return `${start.format('ddd, D MMMM')} (${short_hour(start)}) - ${end.format('ddd, D MMMM')} (${short_hour(end)})`
} else {
if (event.end_datetime && event.end_datetime !== event.start_datetime)
return moment(event.start_datetime).format('dddd, D MMMM HH:mm') + '-' + moment(event.end_datetime).format('HH:mm')
return `${start.format('ddd, D MMMM')} (${short_hour(start)}-${short_hour(end)}`
else
return moment(event.start_datetime).format('dddd, D MMMM HH:mm')
return `${start.format('dddd, D MMMM')} (${short_hour(start)})`
}
})
}