Skip to content

Commit 7a406b0

Browse files
committed
try to fixe timezone offset
1 parent 60b0a22 commit 7a406b0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/utils/icsGenerator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
function formatICSDate(date: Date): string {
2-
return date.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z';
2+
// Convert to UTC for iCalendar format
3+
// We need to preserve the original time in the user's timezone
4+
// but format it according to iCalendar specs (UTC/Z format)
5+
const userTimezoneDate = new Date(date);
6+
return userTimezoneDate.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z';
37
}
48

59
export function generateICS(event: {
@@ -11,7 +15,7 @@ export function generateICS(event: {
1115
}) {
1216
// Events are typically 2 hours long
1317
const endDate = new Date(event.startDate.getTime() + 2 * 60 * 60 * 1000);
14-
18+
1519
const description = [
1620
event.description,
1721
`Location: ${event.location}`,

0 commit comments

Comments
 (0)