Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/12_hour_time.rb

Overview

:nodoc: all

Instance Method Summary collapse

Instance Method Details

#instantiate_time_object_with_ampm(name, values) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/12_hour_time.rb', line 18

def instantiate_time_object_with_ampm(name, values)
  if values.last < 0
    ampm = values.pop
    if ampm == ActionView::Helpers::DateTimeSelector::AM and values[3] == 12
      values[3] = 0
    elsif ampm == ActionView::Helpers::DateTimeSelector::PM and values[3] != 12
      values[3] += 12
    end
  end

  instantiate_time_object_without_ampm(name, values)
end