@@ -79,26 +79,48 @@ export class DateGeneratorBaseStrategy {
7979 const { isRecurrent } = appointmentAdapter ;
8080
8181 const itemGroupIndices = this . _getGroupIndices ( this . rawAppointment ) ;
82+ let dateSettings ;
8283
83- let sourceList = this . _createAppointments ( appointmentAdapter , itemGroupIndices ) ;
84- sourceList = this . excludeLocalDST ( sourceList , appointmentAdapter ) ;
85- sourceList = this . _getProcessedByAppointmentTimeZone ( sourceList , appointmentAdapter ) ; // T983264
84+ if ( appointmentAdapter . isRecurrent && appointmentAdapter . startDateTimeZone ) {
85+ let sourceList = this . _createAppointments ( appointmentAdapter , itemGroupIndices ) ;
86+ sourceList = this . excludeLocalDST ( sourceList , appointmentAdapter ) ;
87+ sourceList = this . _getProcessedByAppointmentTimeZone ( sourceList , appointmentAdapter ) ; // T983264
8688
87- if ( appointmentAdapter . isRecurrent && appointmentAdapter . recurrenceException ) {
88- const exceptions = new Set ( appointmentAdapter . recurrenceException ?. split ( ',' ) ) ;
89- sourceList = sourceList
90- . filter ( ( item ) => ! exceptions . has ( getAsciiStringByDate ( item . startDate ) ) ) ;
91- }
89+ if ( appointmentAdapter . isRecurrent && appointmentAdapter . recurrenceException ) {
90+ const exceptions = new Set ( appointmentAdapter . recurrenceException ?. split ( ',' ) ) ;
91+ sourceList = sourceList
92+ . filter ( ( item ) => ! exceptions . has ( getAsciiStringByDate ( item . startDate ) ) ) ;
93+ }
94+
95+ let appointmentList = sourceList ;
96+ if ( appointmentAdapter . isRecurrent && (
97+ ! this . timeZone
98+ || timeZoneUtils . isEqualLocalTimeZone ( this . timeZone )
99+ ) ) {
100+ appointmentList = this . _getProcessedNativeTimezoneDates ( appointmentList , appointmentAdapter ) ;
101+ }
102+
103+ dateSettings = this . _createGridAppointmentList ( appointmentList , sourceList , appointmentAdapter ) ;
104+ } else {
105+ let appointmentList = this . _createAppointments ( appointmentAdapter , itemGroupIndices ) ;
106+
107+ appointmentList = this . _getProcessedByAppointmentTimeZone ( appointmentList , appointmentAdapter ) ; // T983264
92108
93- let appointmentList = sourceList ;
94- if ( appointmentAdapter . isRecurrent && (
95- ! this . timeZone
96- || timeZoneUtils . isEqualLocalTimeZone ( this . timeZone )
97- ) ) {
98- appointmentList = this . _getProcessedNativeTimezoneDates ( appointmentList , appointmentAdapter ) ;
109+ if ( this . _canProcessNotNativeTimezoneDates ( appointmentAdapter ) ) {
110+ appointmentList = this . _getProcessedNotNativeTimezoneDates ( appointmentList , appointmentAdapter ) ;
111+ }
112+
113+ appointmentList = this . excludeLocalDST ( appointmentList , appointmentAdapter ) ;
114+ dateSettings = this . _createGridAppointmentList ( appointmentList , appointmentList , appointmentAdapter ) ;
99115 }
100116
101- let dateSettings = this . _createGridAppointmentList ( appointmentList , sourceList , appointmentAdapter ) ;
117+ dateSettings = dateSettings . map ( ( item ) => ( {
118+ ...item ,
119+ savedBeforeSplit : {
120+ startDate : new Date ( item . startDate ) ,
121+ endDate : new Date ( item . endDate ) ,
122+ } ,
123+ } ) ) ;
102124
103125 const firstViewDates = this . _getAppointmentsFirstViewDate ( dateSettings ) ;
104126
@@ -161,6 +183,36 @@ export class DateGeneratorBaseStrategy {
161183 return appointmentList ;
162184 }
163185
186+ _getProcessedNotNativeTimezoneDates ( appointmentList , appointment ) {
187+ return appointmentList . map ( ( item ) => {
188+ let diffStartDateOffset = this . _getCommonOffset ( appointment . startDate ) - this . _getCommonOffset ( item . startDate ) ;
189+ let diffEndDateOffset = this . _getCommonOffset ( appointment . endDate ) - this . _getCommonOffset ( item . endDate ) ;
190+
191+ if ( diffStartDateOffset === 0 && diffEndDateOffset === 0 ) {
192+ return item ;
193+ }
194+
195+ diffStartDateOffset = this . _getProcessedNotNativeDateIfCrossDST ( item . startDate , diffStartDateOffset ) ;
196+ diffEndDateOffset = this . _getProcessedNotNativeDateIfCrossDST ( item . endDate , diffEndDateOffset ) ;
197+
198+ const newStartDate = new Date ( item . startDate . getTime ( ) + diffStartDateOffset * toMs ( 'hour' ) ) ;
199+ let newEndDate = new Date ( item . endDate . getTime ( ) + diffEndDateOffset * toMs ( 'hour' ) ) ;
200+
201+ const testNewStartDate = this . timeZoneCalculator . createDate ( newStartDate , 'toGrid' ) ;
202+ const testNewEndDate = this . timeZoneCalculator . createDate ( newEndDate , 'toGrid' ) ;
203+
204+ if ( appointment . duration > testNewEndDate . getTime ( ) - testNewStartDate . getTime ( ) ) {
205+ newEndDate = new Date ( newStartDate . getTime ( ) + appointment . duration ) ;
206+ }
207+
208+ return {
209+ ...item ,
210+ startDate : newStartDate ,
211+ endDate : newEndDate ,
212+ } ;
213+ } ) ;
214+ }
215+
164216 _createAppointments ( appointment , groupIndices ) {
165217 let appointments = this . _createRecurrenceAppointments ( appointment , groupIndices ) ;
166218
0 commit comments