Code Duplication    Length = 4-4 lines in 4 locations

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/Post.php 1 location

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

Sources/Subs-Calendar.php 2 locations

@@ 683-686 (lines=4) @@
680
	}
681
682
	// Give birthdays and holidays a friendly format, without the year
683
	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
684
		$date_format = '%b %d';
685
	else
686
		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
687
688
	foreach (array('birthdays', 'holidays') as $type)
689
	{
@@ 1557-1560 (lines=4) @@
1554
		$date_format = $matches[0];
1555
1556
	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1557
	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1558
		$time_format = '%k:%M';
1559
	else
1560
		$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1561
1562
	// Should this be an all day event?
1563
	$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;