import Vue from 'vue' import TimeAgo from 'javascript-time-ago' import ru from 'javascript-time-ago/locale/ru' export default ({ app }, inject) => { const convertDate = (date) => { TimeAgo.addLocale(ru) const timeAgo = new TimeAgo('ru-RU') if ((date + (24*3600))* 1000 > Date.now()) { return timeAgo.format(date * 1000) } else { return timeAgo.format(date * 1000, 'twitter') } } inject('convertDate', convertDate) }