/** * When a manager can pick up the phone. Outside these hours the landing stops * offering a direct call: every `tel:` link opens the callback form instead, * and the lead is flagged so it is handled first thing on the next working day. */ export const businessHours = { timeZone: 'Europe/Samara', /** `Intl` short weekday names, as `formatToParts` returns them in en-US. */ workDays: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'], openMinutes: 9 * 60, closeMinutes: 18 * 60, label: 'Пн–Пт, 09:00–18:00 по самарскому времени', } as const const clock = new Intl.DateTimeFormat('en-US', { timeZone: businessHours.timeZone, weekday: 'short', hour: '2-digit', minute: '2-digit', hourCycle: 'h23', }) export function isWithinBusinessHours(now: Date = new Date()): boolean { const parts: Record = {} for (const part of clock.formatToParts(now)) parts[part.type] = part.value const minutes = Number(parts.hour) * 60 + Number(parts.minute) return ( (businessHours.workDays as readonly string[]).includes(parts.weekday) && minutes >= businessHours.openMinutes && minutes < businessHours.closeMinutes ) }