Use shorter format for ago dates

merge-requests/671/head
Eliot Berriot 2019-03-06 18:42:33 +01:00
rodzic 666aaf0177
commit 6cfad07870
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
2 zmienionych plików z 19 dodań i 3 usunięć

Wyświetl plik

@ -17,7 +17,15 @@ export function ago (date, locale) {
locale = locale || 'en' locale = locale || 'en'
const m = moment(date) const m = moment(date)
m.locale(locale) m.locale(locale)
return m.fromNow() return m.calendar(null, {
sameDay: 'LT',
nextDay: 'L',
nextWeek: 'L',
lastDay: 'L',
lastWeek: 'L',
sameElse: 'L'
})
} }
Vue.filter('ago', ago) Vue.filter('ago', ago)

Wyświetl plik

@ -1,5 +1,5 @@
import {expect} from 'chai' import {expect} from 'chai'
import moment from 'moment'
import {truncate, ago, capitalize, year} from '@/filters' import {truncate, ago, capitalize, year} from '@/filters'
describe('filters', () => { describe('filters', () => {
@ -24,7 +24,15 @@ describe('filters', () => {
it('works', () => { it('works', () => {
const input = new Date() const input = new Date()
let output = ago(input) let output = ago(input)
expect(output).to.equal('a few seconds ago') let expected = moment(input).calendar(input, {
sameDay: 'LT',
nextDay: 'L',
nextWeek: 'L',
lastDay: 'L',
lastWeek: 'L',
sameElse: 'L'
})
expect(output).to.equal(expected)
}) })
}) })
describe('year', () => { describe('year', () => {