Code Duplication    Length = 4-7 lines in 4 locations

Sources/Post.php 1 location

@@ 253-256 (lines=4) @@
250
		isAllowedTo('calendar_post');
251
252
		// We want a fairly compact version of the time, but as close as possible to the user's settings.
253
		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
254
			$time_string = '%k:%M';
255
		else
256
			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
257
258
		$js_time_string = str_replace(
259
			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),

Sources/Calendar.php 1 location

@@ 291-294 (lines=4) @@
288
		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
289
290
	// We want a fairly compact version of the time, but as close as possible to the user's settings.
291
	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
292
		$time_string = '%k:%M';
293
	else
294
		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
295
296
	$js_time_string = str_replace(
297
		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),

Sources/Subs-Calendar.php 2 locations

@@ 691-694 (lines=4) @@
688
	}
689
690
	// Give birthdays and holidays a friendly format, without the year
691
	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
692
		$date_format = '%b %d';
693
	else
694
		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
695
696
	foreach (array('birthdays', 'holidays') as $type)
697
	{
@@ 1558-1564 (lines=7) @@
1555
	}
1556
1557
	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1558
	if (empty($time_format))
1559
	{
1560
		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1561
			$time_format = '%k:%M';
1562
		else
1563
			$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1564
	}
1565
1566
	// Should this be an all day event?
1567
	$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;