Files
lovelope/src/lib/calendar.ts
T
jeanGaston 1064a0362b Initial commit: baseline snapshot before UI/UX refactor
Captures the existing lovelope.app codebase (Next.js App Router,
custom Tailwind components, Prisma) as a rollback point prior to
adopting shadcn/ui and a mobile-first redesign.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-29 19:27:12 +02:00

22 lines
905 B
TypeScript

function toGCalDate(d: Date) {
return d.toISOString().replace(/[-:.]/g, '').slice(0, 15) + 'Z';
}
export function makeIcs(title: string, startsAt: Date, description: string) {
const start = toGCalDate(startsAt);
const end = toGCalDate(new Date(startsAt.getTime() + 60 * 60 * 1000));
return [
'BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//lovelope.app//EN',
'BEGIN:VEVENT',
`DTSTART:${start}`, `DTEND:${end}`,
`SUMMARY:${title}`, `DESCRIPTION:${description}`,
'END:VEVENT', 'END:VCALENDAR',
].join('\r\n');
}
export function makeGCalUrl(title: string, startsAt: Date, description: string) {
const start = toGCalDate(startsAt);
const end = toGCalDate(new Date(startsAt.getTime() + 60 * 60 * 1000));
return `https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(title)}&dates=${start}/${end}&details=${encodeURIComponent(description)}`;
}