gancio-upstream/plugins/filters.js

23 lines
964 B
JavaScript
Raw Normal View History

2019-04-03 00:25:12 +02:00
import Vue from 'vue'
import moment from 'dayjs'
import 'dayjs/locale/it'
moment.locale('it')
2019-05-30 12:04:14 +02:00
export default (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('month', value => moment(value).format('MMM'))
Vue.filter('event_when', event => {
if (event.multidate) {
return moment(event.start_datetime).format('dddd, D MMMM HH:mm') + ' - ' + moment(event.end_datetime).format('ddd, D MMMM')
} 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')
else
return moment(event.start_datetime).format('dddd, D MMMM HH:mm')
}
})
}