aboutsummaryrefslogtreecommitdiff
path: root/mod/event_calendar/views/default/input/timepicker.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/event_calendar/views/default/input/timepicker.php')
-rw-r--r--mod/event_calendar/views/default/input/timepicker.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/mod/event_calendar/views/default/input/timepicker.php b/mod/event_calendar/views/default/input/timepicker.php
new file mode 100644
index 000000000..2cc95ced7
--- /dev/null
+++ b/mod/event_calendar/views/default/input/timepicker.php
@@ -0,0 +1,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));
+}