Skip to content
Snippets Groups Projects
Verified Commit 83a9a6b0 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Use shorter format for ago dates

parent ed1fdc85
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,15 @@ export function ago (date, locale) {
locale = locale || 'en'
const m = moment(date)
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)
......
import {expect} from 'chai'
import moment from 'moment'
import {truncate, ago, capitalize, year} from '@/filters'
describe('filters', () => {
......@@ -24,7 +24,15 @@ describe('filters', () => {
it('works', () => {
const input = new Date()
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', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment