Class: ActiveModel::Type::Time
- Includes:
- Helpers::TimeValue, Helpers::Timezone
- Defined in:
- lib/active_model/type/time.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
Methods included from Helpers::TimeValue
#apply_seconds_precision, #serialize, #type_cast_for_schema
Methods included from Helpers::Timezone
Methods inherited from Value
#==, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #initialize, #map, #serializable?, #serialize, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Constructor Details
This class inherits a constructor from ActiveModel::Type::Value
Instance Method Details
#type ⇒ Object
12 13 14 |
# File 'lib/active_model/type/time.rb', line 12 def type :time end |
#user_input_in_time_zone(value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_model/type/time.rb', line 16 def user_input_in_time_zone(value) return unless value.present? case value when ::String value = "2000-01-01 #{value}" time_hash = ::Date._parse(value) return if time_hash[:hour].nil? when ::Time value = value.change(year: 2000, day: 1, month: 1) end super(value) end |