Code Duplication    Length = 24-26 lines in 2 locations

includes/feeds/google.php 2 locations

@@ 206-231 (lines=26) @@
203
								$google_start = Carbon::createFromDate( $date->year, $date->month, $date->day, $start_timezone )->startOfDay()->addSeconds( 59 );
204
								$google_start_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->addSeconds( 59 );
205
								$whole_day = true;
206
							} else {
207
								$date = Carbon::parse( $event->getStart()->dateTime );
208
209
								// Check if there is an event level timezone
210
								if( $event->getStart()->timeZone && 'use_calendar' == $this->timezone_setting ) {
211
212
									// Get the two different times with the separate timezones so we can check the offsets next
213
									$google_start1 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone );
214
									$google_start2 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getStart()->timeZone );
215
216
									// Get the offset in hours
217
									$offset1 = $google_start1->offsetHours;
218
									$offset2 = $google_start2->offsetHours;
219
220
									// Get the difference between the two timezones
221
									$total_offset = ( $offset2 - $offset1 );
222
223
									// Add the hours offset to the date hour
224
									$date->hour += $total_offset;
225
								}
226
227
								$google_start = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone );
228
								$google_start_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
229
230
								$this->timezone = $start_timezone;
231
							}
232
							// Start.
233
							$start = $google_start->getTimestamp();
234
							// Start UTC.
@@ 253-276 (lines=24) @@
250
									$date           = Carbon::parse( $event->getEnd()->date );
251
									$google_end     = Carbon::createFromDate( $date->year, $date->month, $date->day, $end_timezone )->startOfDay()->subSeconds( 59 );
252
									$google_end_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->subSeconds( 59 );
253
								} else {
254
									$date = Carbon::parse( $event->getEnd()->dateTime );
255
256
									// Check if there is an event level timezone
257
									if( $event->getEnd()->timeZone && 'use_calendar' == $this->timezone_setting ) {
258
259
										// Get the two different times with the separate timezones so we can check the offsets next
260
										$google_start1 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone );
261
										$google_start2 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getEnd()->timeZone );
262
263
										// Get the offset in hours
264
										$offset1 = $google_start1->offsetHours;
265
										$offset2 = $google_start2->offsetHours;
266
267
										// Get the difference between the two timezones
268
										$total_offset = ( $offset2 - $offset1 );
269
270
										// Add the hours offset to the date hour
271
										$date->hour += $total_offset;
272
									}
273
274
									$google_end     = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone );
275
									$google_end_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
276
								}
277
								// End.
278
								$end = $google_end->getTimestamp();
279
								// End UTC.