From 77003a34530242ae84a0deb9f7a42e91ddaa9c3d Mon Sep 17 00:00:00 2001 From: Arth <65160206@go.buu.ac.th> Date: Fri, 28 Mar 2025 09:23:40 +0700 Subject: [PATCH] fix date localhost --- src/components/GanttChart/GanttChart.vue | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/GanttChart/GanttChart.vue b/src/components/GanttChart/GanttChart.vue index 077ad56..cd5b092 100644 --- a/src/components/GanttChart/GanttChart.vue +++ b/src/components/GanttChart/GanttChart.vue @@ -220,12 +220,23 @@ function clearOriginalMaps() { function convertToLocalTime(utcString: string): string { const d = new Date(utcString) - const iso = d.toISOString() - // ๐ข เธเธทเธเนเธเธเนเธกเนเนเธเธฅเธ timezone (เนเธเนเธ•เธฑเธ”เน€เธงเธฅเธฒเนเธซเน format เธชเธงเธข) - return iso.slice(0, 16).replace('T', ' ') + + const isLocalhost = ['localhost', '127.0.0.1'].includes(window.location.hostname) + + if (isLocalhost) { + // ๐ข เนเธเธฅเธเน€เธเนเธ local time (Asia/Bangkok) + d.setHours(d.getHours() + 7) // เธเธฃเธฑเธ +7 เธเธฑเนเธงเนเธกเธ + const iso = d.toISOString() + return iso.slice(0, 16).replace('T', ' ') + } else { + // ๐”ต Prod โ’ เนเธกเนเนเธเธฅเธ timezone, เนเธเน format เธชเธงเธข เน + const iso = d.toISOString() + return iso.slice(0, 16).replace('T', ' ') + } } + // Pagination & Dialog const pages = computed(() => pageStore.pages.map((p) => p.pagenum)) const pageToShowDelete = ref<number | null>(null) -- GitLab