3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/simple_time_select.rb', line 3
def select_minute_with_simple_time_select
return select_minute_without_simple_time_select unless @options[:simple_time_select].eql? true
val_minutes = @datetime.kind_of?(Time) ? @datetime.min + @datetime.hour*60 : @datetime
@options[:time_separator] = ""
minute_interval = 15
if @options[:minute_interval]
minute_interval = @options[:minute_interval]
end
start_minute = 0
if @options[:start_hour]
start_minute = @options[:start_hour] * 60
end
end_minute = 1439
if @options[:end_hour]
end_minute = ( @options[:end_hour] + 1 ) * 60 - 1
end
if @options[:use_hidden] || @options[:discard_minute]
build_hidden(:minute, val)
else
minute_options = []
start_minute.upto(end_minute) do |minute|
if minute%minute_interval == 0
ampm = minute < 720 ? ' AM' : ' PM'
hour = minute/60
minute_padded = zero_pad_num(minute%60)
hour_padded = zero_pad_num(hour)
ampm_hour = ampm_hour(hour)
val = "#{hour_padded}:#{minute_padded}:00"
minute_options << ((val_minutes == minute) ?
%(<option value="#{val}" selected="selected">#{ampm_hour}:#{minute_padded}#{ampm}</option>\n) :
%(<option value="#{val}">#{ampm_hour}:#{minute_padded}#{ampm}</option>\n)
)
end
end
build_select(:minute, minute_options)
end
end
|