File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11function 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
914export function generateICS ( event : {
You can’t perform that action at this time.
0 commit comments