diff --git a/front/src/filters.js b/front/src/filters.js index 145a98253..1edea76f6 100644 --- a/front/src/filters.js +++ b/front/src/filters.js @@ -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) diff --git a/front/tests/unit/specs/filters/filters.spec.js b/front/tests/unit/specs/filters/filters.spec.js index 1464e5c97..f4f3610dc 100644 --- a/front/tests/unit/specs/filters/filters.spec.js +++ b/front/tests/unit/specs/filters/filters.spec.js @@ -1,5 +1,5 @@ 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', () => {