Method: Mongoid::Fields::Internal::Timekeeping#convert_to_time
- Defined in:
- lib/mongoid/fields/internal/timekeeping.rb
#convert_to_time(value) ⇒ Time
Convert the provided object to a UTC time to store in the database.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/mongoid/fields/internal/timekeeping.rb', line 87 def convert_to_time(value) time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time case value when ::String time.parse(value) when ::DateTime return value if value.utc? && Mongoid.use_utc? time.local(value.year, value.month, value.day, value.hour, value.min, value.sec) when ::Date time.local(value.year, value.month, value.day) when ::Array time.local(*value) else value end end |