From 039d6ede24d68d986d23b48ebd7a3b8dff652170 Mon Sep 17 00:00:00 2001 From: puri-ph4tt Date: Mon, 5 Feb 2024 18:01:29 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= =?UTF-8?q?=E0=B8=9C=E0=B8=A5=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=20?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B8=AA=E0=B9=88=E0=B8=A7=E0=B8=99?= =?UTF-8?q?=E0=B8=AD=E0=B8=B7=E0=B9=88=E0=B8=99=E0=B9=80=E0=B8=A5=E0=B9=87?= =?UTF-8?q?=E0=B8=81=E0=B8=99=E0=B9=89=E0=B8=AD=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../00_support/components/ChatMessage.vue | 60 +++++++++++++++---- .../00_support/components/NewIssue.vue | 2 +- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/modules/00_support/components/ChatMessage.vue b/src/modules/00_support/components/ChatMessage.vue index c901ea0..0940cd6 100644 --- a/src/modules/00_support/components/ChatMessage.vue +++ b/src/modules/00_support/components/ChatMessage.vue @@ -4,27 +4,61 @@ import moment from "moment"; import { useSupportStore } from "@/modules/00_support/store/Main"; const store = useSupportStore(); + +function dateChat(timestamp: string): string { + const parsedTimestamp = moment(timestamp); + const diff = moment().diff(parsedTimestamp); + + if (diff < 1000) { + return "just now"; + } else if (diff < 86400000) { + const formattedDate = parsedTimestamp.format("HH:MM") + " น."; + return formattedDate; + } else { + const beYear = parsedTimestamp.year() + 543; + const formattedDate = parsedTimestamp.clone().year(beYear).format("DD MMM"); + return formattedDate; + } +}