--- helpers_form.module 2008-02-13 10:31:19.000000000 -0500 +++ helpers_form.module 2008-06-02 16:23:42.000000000 -0400 @@ -491,3 +491,47 @@ function _helpers_data_month_names_array ); return $names; } + +/* +* This will generate the options for a time selection. Since the parameters for the field are quite +* numerous, and the options is the tough part, this is only the options part. +* +* @param $hour = allows the selection of a 12 hour timeframe. It will default to 24 hour timeframe if this is provided as something other than a 12, and it will default to 12, should nothing be selected. +* @return $time = an array that could be used to fill the options for either a select box or an option field for any type of field. The 'hour' key will provide the hours, the 'minute' key will provide the minutes, the 'second' key will provide the seconds, and if it is a 12 hour select, then the 'ampm' key will provide the selection of AM or PM. +* +*/ + +function time_select_for_form($hour = 12){ + + if ($hour = 12){ + $time = array('hour', 'minute', 'second', 'ampm'); + for($i=1;$i<=12;$i++) + ($i < 10 ? $time['hour']["$i"] = "0$i" : $time['hour'][$i] = "$i"); + + for($i = 0; $i < 60; $i++) + ($i < 10 ? $time['minute']["$i"] = "0$i" : $time['minute']["$i"] = "$i"); + + for($i = 0; $i < 10; $i++) + ($i < 10 ? $time['second']["$i"] = "0$i" : $time['second']["$i"] = "$i"); + + $time['ampm'] = array( + 'am' => 'AM', + 'pm' => 'PM' + ); + + return $time; + }; + else { + $time = array('hour', 'minute', 'second'); + + for($i=1;$i<24;$i++) + ($i < 10 ? $time['hour']["$i"] = "0$i" : $time['hour'][$i] = "$i"); + + for($i = 0; $i < 60; $i++) + ($i < 10 ? $time['minute']["$i"] = "0$i" : $time['minute']["$i"] = "$i"); + + for($i = 0; $i < 10; $i++) + ($i < 10 ? $time['second']["$i"] = "0$i" : $time['second']["$i"] = "$i"); + return $time; + }; +}