diff --git a/frontend/src/utils.js b/frontend/src/utils.js index bfd188b..38ad762 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -2,6 +2,10 @@ import { ToastProgrammatic as Toast, DialogProgrammatic as Dialog, } from 'buefy'; +import dayjs from 'dayjs'; +import relativeTime from 'dayjs/plugin/relativeTime'; + +dayjs.extend(relativeTime); const reEmail = /(.+?)@(.+?)/ig; @@ -27,6 +31,10 @@ export default class utils { return out; }; + static duration(start, end) { + return dayjs(end).from(dayjs(start), true); + } + // Simple, naive, e-mail address check. static validateEmail = (e) => e.match(reEmail); diff --git a/frontend/src/views/Campaign.vue b/frontend/src/views/Campaign.vue index 7ebf441..1b4e4f6 100644 --- a/frontend/src/views/Campaign.vue +++ b/frontend/src/views/Campaign.vue @@ -83,7 +83,8 @@
- {{ duration(stats.startedAt, stats.updatedAt) }} + {{ $utils.duration(stats.startedAt, stats.updatedAt) }}