Fix: gunakan Intl.DateTimeFormat dengan timezone Asia/Jakarta untuk konsistensi di semua browser dan server

This commit is contained in:
mwpn
2025-12-19 05:44:55 +07:00
parent 445e7b82ff
commit 706fd02655
3 changed files with 36 additions and 9 deletions

View File

@@ -94,8 +94,14 @@ class RealtimeManager {
// Struktur response setelah di-unwrap: { total_count_today, total_amount_today, by_gate, by_category }
// Gunakan timezone Indonesia UTC+7 untuk mendapatkan tanggal lokal yang benar
const now = new Date();
const indonesiaTime = new Date(now.getTime() + (7 * 60 * 60 * 1000)); // UTC+7
const today = indonesiaTime.toISOString().split('T')[0];
// Format tanggal dalam timezone Asia/Jakarta (UTC+7)
const formatter = new Intl.DateTimeFormat('en-CA', {
timeZone: 'Asia/Jakarta',
year: 'numeric',
month: '2-digit',
day: '2-digit'
});
const today = formatter.format(now);
const snapshot = await apiGetRealtimeSnapshot({
date: today,
location_code: '' // bisa diambil dari state dashboard jika perlu