diff --git a/index.html b/index.html index 942221d..5a00f95 100644 --- a/index.html +++ b/index.html @@ -186,6 +186,7 @@

Upcoming

Loading...

+

All times shown in your local timezone

diff --git a/js/calendar.js b/js/calendar.js index 7d9d0c4..8cf0a02 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -1,4 +1,4 @@ -// Calendar tab — monthly grid + sidebar + day hover popups +// Calendar tab — country-timezone-aware, auto-converts to your local time const CAL_FB_CONFIG = { apiKey: "AIzaSyDuSjEGEKx5FnWYnQq8f_owbpYRBRrl5x0", authDomain: "esef-514bf.firebaseapp.com", @@ -12,6 +12,20 @@ const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; const MONTHS = ["January","February","March","April","May","June", "July","August","September","October","November","December"]; +function fmtTime(utcIso, time, country) { + if (utcIso) { + try { + var d = new Date(utcIso); + if (!isNaN(d.getTime())) { + var local = d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); + if (country) local += " (" + country + ")"; + return local; + } + } catch (e) {} + } + return (time || "") + (country ? " (" + country + ")" : ""); +} + document.addEventListener("DOMContentLoaded", () => { const tab = document.getElementById("calendar"); if (!tab) return; @@ -35,11 +49,14 @@ document.addEventListener("DOMContentLoaded", () => { title: d.title || "", date: d.date || "", time: d.time || "", + country: d.country || "", + utc: d.utc || "", description: d.description || "", - createdBy: d.createdBy || "" + createdBy: d.createdBy || "", + _sort: d.utc || (d.date + "T" + (d.time || "00:00")) }); }); - allEvents.sort((a, b) => (a.date + a.time).localeCompare(b.date + b.time)); + allEvents.sort((a, b) => a._sort.localeCompare(b._sort)); render(); }, () => { if (gridEl) gridEl.innerHTML = '

Could not load.

'; @@ -53,14 +70,12 @@ document.addEventListener("DOMContentLoaded", () => { const month = viewDate.getMonth(); navEl.textContent = MONTHS[month] + " " + year; - // Group events by date for quick lookup const byDate = {}; allEvents.forEach(e => { if (!byDate[e.date]) byDate[e.date] = []; byDate[e.date].push(e); }); - // Build grid const firstDay = new Date(year, month, 1).getDay(); const daysInMonth = new Date(year, month + 1, 0).getDate(); const today = new Date(); @@ -86,17 +101,16 @@ document.addEventListener("DOMContentLoaded", () => { html += '
'; - html += '
' + d + "
"; - if (hasEvents) { - // Dot indicators - dayEvents.forEach(() => html += ''); - // Hover popup + if (hasEvents) { + dayEvents.forEach(() => html += ''); html += '

' + dateStr + "

"; dayEvents.forEach(e => { html += '
'; - if (e.time) html += '' + e.time + ""; + if (e.time) { + html += '' + fmtTime(e.utc, e.time, e.country) + " "; + } html += esc(e.title); if (e.description) html += '
' + esc(e.description) + "
"; html += "
"; @@ -108,14 +122,14 @@ document.addEventListener("DOMContentLoaded", () => { gridEl.innerHTML = html; - // Sidebar: upcoming events const upcoming = allEvents.filter(e => e.date >= todayStr); if (upcoming.length === 0) { - sidebarEl.innerHTML = '

No upcoming events.
Use !book in Discord.

'; + sidebarEl.innerHTML = '

No upcoming events.
Use /book in Discord.

'; } else { sidebarEl.innerHTML = upcoming.slice(0, 15).map(e => '
' + - '
' + e.date + (e.time ? " at " + e.time : "") + "
" + + '
' + e.date + + (e.time ? " " + fmtTime(e.utc, e.time, e.country) : "") + "
" + '
' + esc(e.title) + "
" + (e.description ? '
' + esc(e.description) + "
" : "") + "
" diff --git a/style/calendar.css b/style/calendar.css index 00f5182..54de9ec 100644 --- a/style/calendar.css +++ b/style/calendar.css @@ -116,3 +116,5 @@ text-align: center; color: rgba(255,255,255,0.2); padding: 30px 0; font-family: Arial, sans-serif; font-size: 0.8rem; } + +.cal-tz-note { font-size: 0.65rem; color: rgba(255,255,255,0.18); text-align: center; margin-top: 16px; } \ No newline at end of file