navegadorsrc/scripts/shop-status.js
function canary(d) {
const f = new Intl.DateTimeFormat('en-CA', {
timeZone: 'Atlantic/Canary', year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', hourCycle: 'h23', weekday: 'short',
});
const p = Object.fromEntries(f.formatToParts(d).map((x) => [x.type, x.value]));
const dow = { Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6 }[p.weekday];
return { date: `${p.year}-${p.month}-${p.day}`, dow, mins: Number(p.hour) * 60 + Number(p.minute) };
}
const toMins = (hhmm) => Number(hhmm.slice(0, 2)) * 60 + Number(hhmm.slice(3, 5));
const workday = (c) => (HOURS[c.dow] && !HOLIDAYS.has(c.date) ? HOURS[c.dow] : null);
export function shopStatus(now = new Date()) {
const c = canary(now);
const h = workday(c);
if (h && c.mins >= toMins(h[0]) && c.mins < toMins(h[1])) return { open: true, closes: h[1] };
// …
}
La web sabe sola si el taller está abierto: hora de Tenerife con horario de verano y festivos, del mismo origen que los datos para Google.