Module: SchedulerHelper

Defined in:
app/helpers/scheduler_helper.rb

Instance Method Summary collapse

Instance Method Details

#time_options_for_schedulerObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/scheduler_helper.rb', line 4

def time_options_for_scheduler
  options = []
  (0..23).each do |hour|
    [0, 15, 30, 45].each do |min|
      t = Time.zone.parse("2000-01-01 #{hour}:#{format('%02d', min)}")
      value = t.strftime('%H:%M')
      label = t.strftime('%-l:%M %p')
      options << [label, value]
    end
  end
  options
end

#time_options_for_scheduler_raw(selected = '09:00') ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/scheduler_helper.rb', line 17

def time_options_for_scheduler_raw(selected = '09:00')
  options = []
  (0..23).each do |hour|
    [0, 15, 30, 45].each do |min|
      t = Time.zone.parse("2000-01-01 #{hour}:#{format('%02d', min)}")
      value = t.strftime('%H:%M')
      label = t.strftime('%-l:%M %p')
      sel = value == selected ? ' selected' : ''
      options << %(<option value="#{value}"#{sel}>#{label}</option>)
    end
  end
  options.join.html_safe
end