Fix: gunakan timezone Indonesia UTC+7 untuk mendapatkan tanggal lokal yang benar
This commit is contained in:
@@ -767,9 +767,12 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
}
|
||||
|
||||
// Set default date ke hari ini (selalu update ke hari ini setiap kali page load)
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
// 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];
|
||||
state.date = today;
|
||||
console.log('[Dashboard] Default date set to today:', state.date);
|
||||
console.log('[Dashboard] Default date set to today (Indonesia timezone):', state.date, 'UTC time:', now.toISOString());
|
||||
|
||||
// Set dateInput value SECARA LANGSUNG untuk override browser cache/autofill
|
||||
// Lakukan ini SEBELUM setupFilters() untuk memastikan value ter-set dengan benar
|
||||
|
||||
@@ -92,8 +92,12 @@ class RealtimeManager {
|
||||
async fetchSnapshot() {
|
||||
try {
|
||||
// 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];
|
||||
const snapshot = await apiGetRealtimeSnapshot({
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
date: today,
|
||||
location_code: '' // bisa diambil dari state dashboard jika perlu
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user