Code Duplication    Length = 4-4 lines in 4 locations

Sources/Post.php 1 location

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

Sources/Calendar.php 1 location

@@ 301-304 (lines=4) @@
298
		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
299
300
	// We want a fairly compact version of the time, but as close as possible to the user's settings.
301
	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
302
		$time_string = '%k:%M';
303
	else
304
		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
305
306
	$js_time_string = str_replace(
307
		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),

Sources/Subs-Calendar.php 2 locations

@@ 654-657 (lines=4) @@
651
	}
652
653
	// Give birthdays and holidays a friendly format, without the year
654
	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
655
		$date_format = '%b %d';
656
	else
657
		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
658
659
	foreach (array('birthdays', 'holidays') as $type)
660
	{
@@ 1528-1531 (lines=4) @@
1525
		$date_format = $matches[0];
1526
1527
	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1528
	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1529
		$time_format = '%k:%M';
1530
	else
1531
		$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1532
1533
	// Should this be an all day event?
1534
	$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;