@@ -64,8 +64,14 @@ export async function findScheduleInboxAvailability() {
6464
6565 const vcalendarComp = new ICAL . Component ( parsedIcal )
6666 const vavailabilityComp = vcalendarComp . getFirstSubcomponent ( 'vavailability' )
67- const availableComps = vavailabilityComp . getAllSubcomponents ( 'available' )
6867
68+ let timezoneId
69+ const timezoneComp = vcalendarComp . getFirstSubcomponent ( 'vtimezone' )
70+ if ( timezoneComp ) {
71+ timezoneId = timezoneComp . getFirstProperty ( 'tzid' ) . getFirstValue ( )
72+ }
73+
74+ const availableComps = vavailabilityComp . getAllSubcomponents ( 'available' )
6975 // Combine all AVAILABLE blocks into a week of slots
7076 const slots = getEmptySlots ( )
7177 availableComps . forEach ( ( availableComp ) => {
@@ -90,6 +96,7 @@ export async function findScheduleInboxAvailability() {
9096
9197 return {
9298 slots,
99+ timezoneId,
93100 }
94101}
95102
@@ -99,6 +106,14 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
99106 day : dayId ,
100107 } ) ) ) ]
101108
109+ const vcalendarComp = new ICAL . Component ( 'vcalendar' )
110+
111+ // Store time zone info
112+ const timezoneComp = new ICAL . Component ( 'vtimezone' )
113+ timezoneComp . addPropertyWithValue ( 'tzid' , timezoneId )
114+ vcalendarComp . addSubcomponent ( timezoneComp )
115+
116+ // Store availability info
102117 const vavailabilityComp = new ICAL . Component ( 'vavailability' )
103118
104119 // Deduplicate by start and end time
@@ -127,7 +142,6 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
127142 const availableComp = new ICAL . Component ( 'available' )
128143
129144 // Define DTSTART and DTEND
130- // TODO: tz? moment.tz(dateTime, timezone).toDate()
131145 const startTimeProp = availableComp . addPropertyWithValue ( 'dtstart' , ICAL . Time . fromJSDate ( start , false ) )
132146 startTimeProp . setParameter ( 'tzid' , timezoneId )
133147 const endTimeProp = availableComp . addPropertyWithValue ( 'dtend' , ICAL . Time . fromJSDate ( end , false ) )
@@ -147,7 +161,6 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
147161 return availableComp
148162 } ) . map ( vavailabilityComp . addSubcomponent . bind ( vavailabilityComp ) )
149163
150- const vcalendarComp = new ICAL . Component ( 'vcalendar' )
151164 vcalendarComp . addSubcomponent ( vavailabilityComp )
152165 logger . debug ( 'New availability ical created' , {
153166 asObject : vcalendarComp ,
0 commit comments