From 7808d14a49884f55fbeb3fd2d16eed9a34760ad7 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Thu, 22 Feb 2018 23:34:52 +0100
Subject: [PATCH] Human date component

---
 front/src/components/common/HumanDate.vue   | 8 ++++++++
 front/src/components/discussion/Comment.vue | 2 +-
 front/src/components/globals.js             | 7 +++++++
 front/src/main.js                           | 1 +
 4 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 front/src/components/common/HumanDate.vue
 create mode 100644 front/src/components/globals.js

diff --git a/front/src/components/common/HumanDate.vue b/front/src/components/common/HumanDate.vue
new file mode 100644
index 0000000000..ff6ff5c71e
--- /dev/null
+++ b/front/src/components/common/HumanDate.vue
@@ -0,0 +1,8 @@
+<template>
+  <time :datetime="date" :title="date | moment">{{ date | ago }}</time>
+</template>
+<script>
+export default {
+  props: ['date']
+}
+</script>
diff --git a/front/src/components/discussion/Comment.vue b/front/src/components/discussion/Comment.vue
index c10d13bc04..a3c5176ecb 100644
--- a/front/src/components/discussion/Comment.vue
+++ b/front/src/components/discussion/Comment.vue
@@ -3,7 +3,7 @@
     <div class="content">
       <a class="author">{{ user.username }}</a>
       <div class="metadata">
-        <div class="date">{{ date | ago }}</div>
+        <div class="date"><human-date :date="date"></human-date></div>
       </div>
       <div class="text" v-html="comment"></div>
       </div>
diff --git a/front/src/components/globals.js b/front/src/components/globals.js
new file mode 100644
index 0000000000..40315bc47d
--- /dev/null
+++ b/front/src/components/globals.js
@@ -0,0 +1,7 @@
+import Vue from 'vue'
+
+import HumanDate from '@/components/common/HumanDate'
+
+Vue.component('human-date', HumanDate)
+
+export default {}
diff --git a/front/src/main.js b/front/src/main.js
index 33e998ded9..2e351310a1 100644
--- a/front/src/main.js
+++ b/front/src/main.js
@@ -14,6 +14,7 @@ import store from './store'
 import config from './config'
 import { sync } from 'vuex-router-sync'
 import filters from '@/filters' // eslint-disable-line
+import globals from '@/components/globals' // eslint-disable-line
 
 sync(store, router)
 
-- 
GitLab