/**
 * Returns three <select> tags populated with hours, minutes, and optionally seconds.
 *
 * By default, the <i>$value</i> parameter is set to the current hour and minute. To override this, simply pass a valid time
 * or a correctly formatted time array (see example) to the <i>$value</i> parameter. You can also set the <i>$value</i> 
 * parameter to null which will disable the <i>$value</i>, however this will only be useful if you pass 'include_blank' or 
 * 'include_custom' to the <i>$options</i> parameter. To include seconds to the result, use set the 'include_second' option in the 
 * <i>$options</i> parameter to true. <b>Note:</b> The <i>$name</i> parameter will automatically converted to array names. 
 * For example, a <i>$name</i> of "time" becomes:
 * <samp>
 *  <select name="time[hour]">...</select>
 *  <select name="time[minute]">...</select>
 *  <select name="time[second]">...</select>
 * </samp>
 *  
 * <b>Options:</b>
 * - include_blank  - Includes a blank <option> tag at the beginning of the string with an empty value.
 * - include_custom - Includes an <option> tag with a custom display title at the beginning of the string with an empty value.
 * - include_second - If set to true, includes the "seconds" select tag as part of the result.
 * - second_step    - If set, the seconds will be incremented in blocks of X, where X = 'second_step'
 * - minute_step    - If set, the minutes will be incremented in blocks of X, where X = 'minute_step'
 * - 12hour_time    - If set to true, will return integers 1 through 12 instead of the default 0 through 23 as well as an AM/PM select box.
 * - time_seperator - Includes a string of defined text between each generated select tag
 * - ampm_seperator - Includes a string of defined text between the minute/second select box and the AM/PM select box 
 *  
 * <b>Examples:</b>
 * <code>
 *  echo select_time_tag('time');
 * </code>
 *
 * <code>
 *  echo select_time_tag('date', '09:31');
 * </code>
 *
 * <code>
 *  $time = array('hour' => '15', 'minute' => 46, 'second' => 01);
 *  echo select_time_tag('time', $time, array('include_second' => true, '12hour_time' => true));
 * </code>
 *
 * @param  string field name (automatically becomes an array of parts: name[hour], name[minute], year[second])
 * @param  mixed  accepts a valid time string or properly formatted time array
 * @param  array  additional HTML compliant <select> tag parameters
 * @return string three <select> tags populated with a hours, minutes and optionally seconds.
 * @see select datetime_tag, select_hour_tag, select_minute_tag, select_second_tag
 */
function select_time_tag($name, $value = null, $options = array(), $html_options = array())
{
    $options = _parse_attributes($options);
    $time_seperator = _get_option($options, 'time_seperator', ':');
    $ampm_seperator = _get_option($options, 'ampm_seperator', '');
    $include_second = _get_option($options, 'include_second');
    $_12hour_time = _get_option($options, '12hour_time');
    $options['12hour_time'] = $_12hour_time;
    // set it back. hour tag needs it.
    if ($include_custom = _get_option($options, 'include_custom')) {
        $include_custom_hour = is_array($include_custom) ? isset($include_custom['hour']) ? array('include_custom' => $include_custom['hour']) : array() : array('include_custom' => $include_custom);
        $include_custom_minute = is_array($include_custom) ? isset($include_custom['minute']) ? array('include_custom' => $include_custom['minute']) : array() : array('include_custom' => $include_custom);
        $include_custom_second = is_array($include_custom) ? isset($include_custom['second']) ? array('include_custom' => $include_custom['second']) : array() : array('include_custom' => $include_custom);
        $include_custom_ampm = is_array($include_custom) ? isset($include_custom['ampm']) ? array('include_custom' => $include_custom['ampm']) : array() : array('include_custom' => $include_custom);
    } else {
        $include_custom_hour = array();
        $include_custom_minute = array();
        $include_custom_second = array();
        $include_custom_ampm = array();
    }
    $tags = array();
    $hour_name = $name . '[hour]';
    $tags[] = select_hour_tag($hour_name, _parse_value_for_date($value, 'hour', $_12hour_time ? 'h' : 'H'), $options + $include_custom_hour, $html_options);
    $minute_name = $name . '[minute]';
    $tags[] = select_minute_tag($minute_name, _parse_value_for_date($value, 'minute', 'i'), $options + $include_custom_minute, $html_options);
    if ($include_second) {
        $second_name = $name . '[second]';
        $tags[] = select_second_tag($second_name, _parse_value_for_date($value, 'second', 's'), $options + $include_custom_second, $html_options);
    }
    $time = implode($time_seperator, $tags);
    if ($_12hour_time) {
        $ampm_name = $name . '[ampm]';
        $time .= $ampm_seperator . select_ampm_tag($ampm_name, _parse_value_for_date($value, 'ampm', 'A'), $options + $include_custom_ampm, $html_options);
    }
    return $time;
}
function my_input_date_tag($name, $value = null, $options = array(), $html_options = array())
{
    $options = _parse_attributes($options);
    $context = sfContext::getInstance();
    $culture = _get_option($options, 'culture', $context->getUser()->getCulture());
    // set it back for month tag
    $options['culture'] = $culture;
    $I18n_arr = _get_I18n_date_locales($culture);
    $date_seperator = _get_option($options, 'date_seperator', $I18n_arr['date_seperator']);
    $include_blank_month = array('include_blank' => _get_option($options, 'include_blank_month', false));
    $include_blank_day = array('include_blank' => _get_option($options, 'include_blank_day', false));
    $include_blank_year = array('include_blank' => _get_option($options, 'include_blank_year', false));
    $order = _get_option($options, 'order');
    $tags = array();
    if (is_array($order) && count($order) == 3) {
        foreach ($order as $v) {
            $tags[] = $v[0];
        }
    } else {
        $tags = $I18n_arr['date_order'];
    }
    $month_name = $name . '[month]';
    $m = select_month_tag($month_name, _parse_value_for_date($value, 'month', 'm'), $options + $include_blank_month, $html_options);
    $day_name = $name . '[day]';
    $d = select_day_tag($day_name, _parse_value_for_date($value, 'day', 'd'), $options + $include_blank_day, $html_options);
    $year_name = $name . '[year]';
    $y = select_year_tag($year_name, _parse_value_for_date($value, 'year', 'Y'), $options + $include_blank_year, $html_options);
    // we have $tags = array ('m','d','y')
    foreach ($tags as $k => $v) {
        // $tags['m|d|y'] = $m|$d|$y
        $tags[$k] = ${$v};
    }
    return implode($date_seperator, $tags);
}