From f9d633e02ba4dc186ffe5f168879c0f9480c89de Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Tue, 28 Sep 2021 08:07:42 +0200 Subject: [PATCH] Display created and updated time in local timezone. Fixes #491 --- src/mixins/datetime.js | 12 ++++++------ src/pages/StatusPage.vue | 21 +++++++++------------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/mixins/datetime.js b/src/mixins/datetime.js index 426ef6d7..7cef22d2 100644 --- a/src/mixins/datetime.js +++ b/src/mixins/datetime.js @@ -1,7 +1,7 @@ import dayjs from "dayjs"; -import utc from "dayjs/plugin/utc"; -import timezone from "dayjs/plugin/timezone"; import relativeTime from "dayjs/plugin/relativeTime"; +import timezone from "dayjs/plugin/timezone"; +import utc from "dayjs/plugin/utc"; dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(relativeTime); @@ -14,7 +14,7 @@ export default { data() { return { userTimezone: localStorage.timezone || "auto", - } + }; }, methods: { @@ -47,11 +47,11 @@ export default { computed: { timezone() { if (this.userTimezone === "auto") { - return dayjs.tz.guess() + return dayjs.tz.guess(); } - return this.userTimezone + return this.userTimezone; }, } -} +}; diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 42a15af0..4f00e08f 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -90,9 +90,9 @@
- Created: {{ incident.createdDate }} ({{ createdDateFromNow }})
+ Created: {{ $root.datetime(incident.createdDate) }} ({{ dateFromNow(incident.createdDate) }})
- Last Updated: {{ incident.lastUpdatedDate }} ({{ lastUpdatedDateFromNow }}) + Last Updated: {{ $root.datetime(incident.lastUpdatedDate) }} ({{ dateFromNow(incident.lastUpdatedDate) }})
@@ -157,7 +157,7 @@
- +
@@ -343,14 +343,6 @@ export default { return this.overallStatus === STATUS_PAGE_ALL_DOWN; }, - createdDateFromNow() { - return dayjs.utc(this.incident.createdDate).fromNow(); - }, - - lastUpdatedDateFromNow() { - return dayjs.utc(this.incident. lastUpdatedDate).fromNow(); - } - }, watch: { @@ -548,7 +540,12 @@ export default { this.$root.getSocket().emit("unpinIncident", () => { this.incident = null; }); - } + }, + + dateFromNow(date) { + return dayjs.utc(date).fromNow(); + }, + } };