aboutsummaryrefslogtreecommitdiff
path: root/mod/event_calendar/views/default/input/timepicker.php
blob: 2cc95ced7825b6b9968c6da784d9baf2d740112a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
$time_format = elgg_get_plugin_setting('timeformat', 'event_calendar');
if (!$time_format) {
	$time_format = '24';
}

$value = $vars['value'];
if (is_numeric($value)) {
	$hour = floor($value/60);
	$minute = ($value -60*$hour);	
} else {
	$hour = 0;
	$minute = 0;
}

$hours = array();
$minutes = array();

if ($time_format == '12') {
	$meridians = array('am'=>'am','pm'=>'pm');
	if ($hour == 0) {
		$hour = 12;
		$meridian = 'am';
	} else if ($hour == 12) {
		$meridian = 'pm';
	} else if ($hour < 12) {
		$meridian = 'am';
	} else {
		$hour -= 12;
		$meridian = 'pm';
	}
	for($h=1;$h<=12;$h++) {
		$hours[$h] = $h;
	}
} else {
	for($h=0;$h<=23;$h++) {
		$hours[$h] = $h;
	}
}	

for($m=0;$m<60;$m=$m+5) {
	$mt = sprintf("%02d",$m);
	$minutes[$m] = $mt;
}

echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_hour','value'=>$hour,'options_values'=>$hours));
echo " <b>:</b> ";
echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_minute','value'=>$minute,'options_values'=>$minutes));
if ($time_format == '12') {
	echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_meridian','value'=>$meridian,'options_values'=>$meridians));
}