/** * Форматирование дат для UI блокировки источника и баннера нового проекта. * Спека: docs/superpowers/specs/2026-06-22-project-source-edit-lock-ux-design.md. */ /** ISO-строку → «23 июня» (ru). Пусто/невалид → ''. */ export function formatLeadDate(iso: string | null | undefined): string { if (!iso) return ''; const d = new Date(iso); if (Number.isNaN(d.getTime())) return ''; return new Intl.DateTimeFormat('ru-RU', { day: 'numeric', month: 'long' }).format(d); } /** * Дата старта лидов нового проекта по правилу слепка 18:00 МСК: * создал до 18:00 МСК → лиды с завтра; после 18:00 → с послезавтра. * РФ круглый год UTC+3 (без перехода на летнее время). */ export function firstLeadDate(now: Date = new Date()): string { const msk = new Date(now.getTime() + 3 * 3600 * 1000); const addDays = msk.getUTCHours() >= 18 ? 2 : 1; const target = new Date(Date.UTC(msk.getUTCFullYear(), msk.getUTCMonth(), msk.getUTCDate() + addDays)); return new Intl.DateTimeFormat('ru-RU', { day: 'numeric', month: 'long', timeZone: 'UTC' }).format(target); }