Module: GBDate::ActiveRecord::Type::Time
- Defined in:
- lib/gb_date/active_record/type/time.rb
Constant Summary collapse
- SECONDS_A_DAY =
86400- DISTANCE_TO_DEFAULT_DAY =
946684800
Instance Method Summary collapse
Instance Method Details
#cast_value(value) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/gb_date/active_record/type/time.rb', line 8 def cast_value(value) return ::Time.at(calculate_float_value value) if value.is_a? Numeric if value.is_a?(::String) && value =~ ::ActiveRecord::ConnectionAdapters::Column::Format::NUMERIC_TIME return ::Time.at(calculate_float_value value) end super value end |
#fast_string_to_time(string) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/gb_date/active_record/type/time.rb', line 16 def fast_string_to_time(string) if string =~ ::ActiveRecord::ConnectionAdapters::Column::Format::NUMERIC_TIME ::Time.at(string.to_f) else super string end end |