- function dayNote(utcH, offset) {
- const adjusted = utcH + offset;
- if (adjusted < 0) return '<span class="day-note">prev day</span>';
- if (adjusted >= 24) return '<span class="day-note">next day</span>';
- return '';
+ // ── Detect user's timezone and current UTC hour ───────────────
+ function getUserTzInfo() {
+ const tzName = Intl.DateTimeFormat().resolvedOptions().timeZone || 'Unknown';
+ const now = new Date();
+
+ // Current UTC hour (0-23)
+ const utcHour = now.getUTCHours();
+
+ // Get the user's current local offset from UTC in hours (includes DST)
+ const localOffsetMin = -now.getTimezoneOffset(); // minutes; positive = east of UTC
+ const localOffsetH = localOffsetMin / 60;
+
+ return { tzName, utcHour, localOffsetH };
+ }
+
+ // ── Determine which chart column matches the user ────────────
+ // Columns: utc, ca, oh, ar
+ // We match based on the user's current UTC offset.
+ // ca: -7 (DST) / -8 (std), oh: -4 (DST) / -5 (std), ar: -3 always
+ // If none match exactly, return null (user's tz isn't one of the four).
+ function matchUserColumn(localOffsetH, isDst) {
+ const caOff = isDst ? -7 : -8;
+ const ohOff = isDst ? -4 : -5;
+ const arOff = -3;
+ const utcOff = 0;
+
+ if (Math.abs(localOffsetH - caOff) < 0.01) return 'ca';
+ if (Math.abs(localOffsetH - ohOff) < 0.01) return 'oh';
+ if (Math.abs(localOffsetH - arOff) < 0.01) return 'ar';
+ if (Math.abs(localOffsetH - utcOff) < 0.01) return 'utc';
+ return null;