method
string_to_time
v1.2.6 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::Column
string_to_time(string)public
No documentation available.
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 112
def self.string_to_time(string)
return string unless string.is_a?(String)
time_hash = Date._parse(string)
time_hash[:sec_fraction] = microseconds(time_hash)
time_array = time_hash.values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction)
# treat 0000-00-00 00:00:00 as nil
Time.send(Base.default_timezone, *time_array) rescue DateTime.new(*time_array[0..5]) rescue nil
end