From b8c3767f8c790febb35141919936d616d3ebe2d4 Mon Sep 17 00:00:00 2001 From: Kevin Jardine Date: Thu, 24 May 2012 20:00:18 +0200 Subject: changed time handling and added more suppport for event polls --- views/default/input/timepicker.php | 90 ++++++++++++-------------------------- 1 file changed, 29 insertions(+), 61 deletions(-) (limited to 'views/default/input/timepicker.php') diff --git a/views/default/input/timepicker.php b/views/default/input/timepicker.php index ccbb88778..2cc95ced7 100644 --- a/views/default/input/timepicker.php +++ b/views/default/input/timepicker.php @@ -1,5 +1,4 @@ 'am','pm'=>'pm'); + if ($hour == 0) { + $hour = 12; + $meridian = 'am'; + } else if ($hour == 12) { + $meridian = 'pm'; + } else if ($hour < 12) { + $meridian = 'am'; } else { - $h1 = 0; - $h2 = 11; + $hour -= 12; + $meridian = 'pm'; } - for($h=$h1;$h<=12;$h++) { - $ht = sprintf("%02d",$h); - for($m=0;$m<60;$m=$m+15) { - $mt = sprintf("%02d",$m); - $t = $h*60+$m; - if ($h < 12) { - $dates[$t] = "$ht:$mt am"; - } else { - $dates[$t] = "$ht:$mt pm"; - } - } - } - for($h=1;$h<$h2;$h++) { - $ht = sprintf("%02d",$h); - for($m=0;$m<60;$m=$m+15) { - $mt = sprintf("%02d",$m); - $t = 12*60+$h*60+$m; - $dates[$t] = "$ht:$mt pm"; - } - } - if ($event_calendar_restricted_times == 'yes') { - $m = 0; - $h = 9; - $ht = sprintf("%02d",$h); - $mt = sprintf("%02d",$m); - $t = 12*60+$h*60+$m; - $dates[$t] = "$ht:$mt pm"; + for($h=1;$h<=12;$h++) { + $hours[$h] = $h; } } else { - if ($event_calendar_restricted_times == 'yes') { - $h1 = 6; - $h2 = 21; - } else { - $h1 = 0; - $h2 = 24; - } - for($h=$h1;$h<$h2;$h++) { - $ht = sprintf("%02d",$h); - for($m=0;$m<60;$m=$m+15) { - $mt = sprintf("%02d",$m); - $t = $h*60+$m; - $dates[$t] = "$ht:$mt"; - } - } - if ($event_calendar_restricted_times == 'yes') { - $m = 0; - $h = 21; - $ht = sprintf("%02d",$h); - $mt = sprintf("%02d",$m); - $t = 12*60+$h*60+$m; - $dates[$t] = "$ht:$mt pm"; + for($h=0;$h<=23;$h++) { + $hours[$h] = $h; } -} +} -echo elgg_view('input/dropdown',array('name'=>$vars['name'],'value'=>$time,'options_values'=>$dates)); +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 " : "; +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)); +} -- cgit v1.2.3