diff options
Diffstat (limited to 'views/default/input/timepicker.php')
-rw-r--r-- | views/default/input/timepicker.php | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/views/default/input/timepicker.php b/views/default/input/timepicker.php index faadd6450..d7df04699 100644 --- a/views/default/input/timepicker.php +++ b/views/default/input/timepicker.php @@ -2,37 +2,52 @@ $time_format = elgg_get_plugin_setting('timeformat', 'event_calendar'); if (!$time_format) { - $time_format = 24; + $time_format = '24'; } $value = $vars['value']; if (is_numeric($value)) { $hour = floor($value/60); - $minute = ($value -60*$hour); - - // add 1 to avoid pulldown 0 bug - $hour++; - $minute++; + $minute = ($value -60*$hour); + $time = $hour*60+$minute; } else { - $hour = '-'; - $minute = '-'; + $time = '-'; } -$hours = array(); -$hours['-'] = '-'; - -for($i=0;$i<$time_format;$i++) { - $hours[$i+1] = $i; -} - -$minutes = array(); -$minutes['-'] = '-'; - -for($i=0;$i<60;$i=$i+5) { - $minutes[$i+1] = sprintf("%02d",$i); +$dates = array(); +$dates['-'] = '-'; + +if ($time_format == '12') { + for($h=0;$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<12;$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"; + } + } +} else { + for($h=0;$h<24;$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"; + } + } } -echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_h','value'=>$hour,'options_values'=>$hours)); -echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_m','value'=>$minute,'options_values'=>$minutes)); +echo elgg_view('input/dropdown',array('name'=>$vars['name'],'value'=>$time,'options_values'=>$dates)); -?>
\ No newline at end of file |