// clock.js — realtime clock + formatted date
export function initClock(clockSelector = "#realTimeClock", dateSelector = "#realTimeDate") {
  const clockEl = document.querySelector(clockSelector);
  const dateEl = document.querySelector(dateSelector);
  if (!clockEl || !dateEl) return;

  function update() {
    const now = new Date();
    const hh = String(now.getHours()).padStart(2, "0");
    const mm = String(now.getMinutes()).padStart(2, "0");
    const ss = String(now.getSeconds()).padStart(2, "0");
    clockEl.textContent = `${hh}:${mm}:${ss}`;

    const dateStr = now.toLocaleDateString("id-ID", { weekday: "long", day: "numeric", month: "long", year: "numeric" });
    dateEl.textContent = dateStr;
  }

  update();
  setInterval(update, 1000);
}
