Ticket #9137: dummy_time_parser_returns_nil.diff
| File dummy_time_parser_returns_nil.diff, 1.2 kB (added by kampers, 1 year ago) |
|---|
-
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
old new 124 124 end 125 125 end 126 126 127 # Returns a +Time+ whose date component is set to a dummy value, to represent 128 # the value of database columns of type +time+. These column types 129 # usually store only time-of-day information, but Ruby has no such 130 # time-only type. 131 # 132 # Returns a +Time+ corresponding to the parsed time-of-day on January 1, 2000, 133 # with <tt>Base.default_timezone</tt> appended, or +nil+ if the string input 134 # cannot be parsed. 127 135 def self.string_to_dummy_time(string) 128 136 return string unless string.is_a?(String) 129 137 return nil if string.empty? 130 138 time_hash = Date._parse(string) 139 return nil if time_hash.empty? 131 140 time_hash[:sec_fraction] = microseconds(time_hash) 132 141 # pad the resulting array with dummy date information 133 142 time_array = [2000, 1, 1]