Skip to content

Commit b45d2cc

Browse files
committed
do no magic here
1 parent 7a406b0 commit b45d2cc

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/utils/icsGenerator.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
function formatICSDate(date: Date): string {
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';
2+
// Extract the local date parts
3+
const year = date.getFullYear();
4+
const month = String(date.getMonth() + 1).padStart(2, '0');
5+
const day = String(date.getDate()).padStart(2, '0');
6+
const hours = String(date.getHours()).padStart(2, '0');
7+
const minutes = String(date.getMinutes()).padStart(2, '0');
8+
const seconds = String(date.getSeconds()).padStart(2, '0');
9+
10+
// Format as YYYYMMDDTHHmmSS
11+
return `${year}${month}${day}T${hours}${minutes}${seconds}Z`;
712
}
813

914
export function generateICS(event: {

0 commit comments

Comments
 (0)