diff --git a/src/components/timeago/timeago.vue b/src/components/timeago/timeago.vue
index 86229349..b46677a6 100644
--- a/src/components/timeago/timeago.vue
+++ b/src/components/timeago/timeago.vue
@@ -2,8 +2,13 @@
@@ -50,3 +55,10 @@ export default {
}
}
+
+
diff --git a/src/services/date_utils/date_utils.js b/src/services/date_utils/date_utils.js
index 677c184c..ab04bec0 100644
--- a/src/services/date_utils/date_utils.js
+++ b/src/services/date_utils/date_utils.js
@@ -6,11 +6,18 @@ export const WEEK = 7 * DAY
export const MONTH = 30 * DAY
export const YEAR = 365.25 * DAY
+const direction = (diff, nowThreshold) => {
+ if (diff < nowThreshold) {
+ return ''
+ }
+ return diff >= 0 ? 'time.in_past' : 'time.in_future'
+}
+
export const relativeTime = (date, nowThreshold = 1) => {
if (typeof date === 'string') date = Date.parse(date)
const round = Date.now() > date ? Math.floor : Math.ceil
const d = Math.abs(Date.now() - date)
- let r = { num: round(d / YEAR), key: 'time.unit.years' }
+ let r = { num: round(d / YEAR), key: 'time.unit.years', direction: direction(d, nowThreshold * SECOND) }
if (d < nowThreshold * SECOND) {
r.num = 0
r.key = 'time.now'