From 8f3611b9e8dcfdcc3a037c12605d9d610542667d Mon Sep 17 00:00:00 2001 From: mwpn Date: Fri, 19 Dec 2025 05:45:21 +0700 Subject: [PATCH] Fix: update getLastAvailableDate dan setTopbarDate untuk gunakan Intl.DateTimeFormat --- public/dashboard/js/dashboard.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/public/dashboard/js/dashboard.js b/public/dashboard/js/dashboard.js index 6d72081..f617b10 100644 --- a/public/dashboard/js/dashboard.js +++ b/public/dashboard/js/dashboard.js @@ -64,9 +64,14 @@ async function getLastAvailableDate() { // Jika tidak, coba kemarin (gunakan timezone Indonesia UTC+7) const now = new Date(); - const indonesiaTime = new Date(now.getTime() + (7 * 60 * 60 * 1000)); // UTC+7 - const yesterday = new Date(indonesiaTime.getTime() - (24 * 60 * 60 * 1000)); - const yesterdayStr = yesterday.toISOString().split('T')[0]; + const yesterdayDate = new Date(now.getTime() - (24 * 60 * 60 * 1000)); + const formatter = new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Jakarta', + year: 'numeric', + month: '2-digit', + day: '2-digit' + }); + const yesterdayStr = formatter.format(yesterdayDate); const yesterdayData = await apiGetSummary({ date: yesterdayStr }); console.log('[Dashboard] getLastAvailableDate - yesterday data:', yesterdayData);