Code Duplication    Length = 22-22 lines in 2 locations

_inc/lib/icalendar-reader.php 2 locations

@@ 334-355 (lines=22) @@
331
									$exdate_compare = date( 'Ymd\THis', $event_start_timestamp );
332
								}
333
334
								if ( in_array( $day, $bydays ) && $event_end_timestamp > $current && $event_start_timestamp < $until && $count_counter <= $rrule_count && $event_start_timestamp >= $date_from_ics && ! in_array( $exdate_compare, $exdates ) ) {
335
									if ( 8 == strlen( $event['DTSTART'] ) ) {
336
										$event['DTSTART'] = date( 'Ymd', $event_start_timestamp );
337
										$event['DTEND'] = date( 'Ymd', $event_end_timestamp );
338
									} else {
339
										$event['DTSTART'] = date( 'Ymd\THis', $event_start_timestamp );
340
										$event['DTEND'] = date( 'Ymd\THis', $event_end_timestamp );
341
									}
342
									if ( $this->timezone->getName() && 8 != strlen( $event['DTSTART'] ) ) {
343
										try {
344
											$adjusted_time = new DateTime( $event['DTSTART'], new DateTimeZone( $this->timezone->getName() ) );
345
											$adjusted_time->setTimeZone( new DateTimeZone( 'UTC' ) );
346
											$event['DTSTART'] = $adjusted_time->format('Ymd\THis');
347
348
											$event['DTEND'] = date( 'Ymd\THis', strtotime( $event['DTSTART'] ) + $duration );
349
										} catch ( Exception $e ) {
350
											// Invalid argument to DateTime
351
										}
352
									}
353
									$upcoming[] = $event;
354
									$count_counter++;
355
								}
356
357
								// Move forward one day
358
								$byday_event_date_start = strtotime( date( 'Ymd\T', strtotime( '+ 1 day', $event_start_timestamp ) ) . $start_time );
@@ 376-397 (lines=22) @@
373
								$exdate_compare = date( 'Ymd\THis', $event_start_timestamp );
374
							}
375
376
							if ( $event_end_timestamp > $current && $event_start_timestamp < $until && $count_counter <= $rrule_count && $event_start_timestamp >= $date_from_ics && ! in_array( $exdate_compare, $exdates ) ) {
377
								if ( 8 == strlen( $event['DTSTART'] ) ) {
378
									$event['DTSTART'] = date( 'Ymd', $event_start_timestamp );
379
									$event['DTEND'] = date( 'Ymd', $event_end_timestamp );
380
								} else {
381
									$event['DTSTART'] = date( 'Ymd\T', $event_start_timestamp ) . $start_time;
382
									$event['DTEND'] = date( 'Ymd\T', $event_end_timestamp ) . $end_time;
383
								}
384
								if ( $this->timezone->getName() && 8 != strlen( $event['DTSTART'] ) ) {
385
									try {
386
										$adjusted_time = new DateTime( $event['DTSTART'], new DateTimeZone( $this->timezone->getName() ) );
387
										$adjusted_time->setTimeZone( new DateTimeZone( 'UTC' ) );
388
										$event['DTSTART'] = $adjusted_time->format('Ymd\THis');
389
390
										$event['DTEND'] = date( 'Ymd\THis', strtotime( $event['DTSTART'] ) + $duration );
391
									} catch ( Exception $e ) {
392
										// Invalid argument to DateTime
393
									}
394
								}
395
								$upcoming[] = $event;
396
								$count_counter++;
397
							}
398
						}
399
400
						// Set up next interval and reset $event['DTSTART'] and $event['DTEND'], keeping timestamps intact