Ticket #4492: timezone.patch
| File timezone.patch, 4.8 kB (added by zenspider, 2 years ago) |
|---|
-
active_record/connection_adapters/abstract/schema_definitions.rb
old new 37 37 case type 38 38 when :integer then Fixnum 39 39 when :float then Float 40 when :datetime_with_timezone then Time 40 41 when :datetime then Time 41 42 when :date then Date 42 43 when :timestamp then Time … … 55 56 when :text then value 56 57 when :integer then value.to_i rescue value ? 1 : 0 57 58 when :float then value.to_f 59 when :datetime_with_timezone then self.class.string_to_time(value) 58 60 when :datetime then self.class.string_to_time(value) 59 61 when :timestamp then self.class.string_to_time(value) 60 62 when :time then self.class.string_to_dummy_time(value) … … 71 73 when :text then nil 72 74 when :integer then "(#{var_name}.to_i rescue #{var_name} ? 1 : 0)" 73 75 when :float then "#{var_name}.to_f" 76 when :datetime_with_timezone then "#{self.class.name}.string_to_time(#{var_name})" 74 77 when :datetime then "#{self.class.name}.string_to_time(#{var_name})" 75 78 when :timestamp then "#{self.class.name}.string_to_time(#{var_name})" 76 79 when :time then "#{self.class.name}.string_to_dummy_time(#{var_name})" … … 108 111 109 112 def self.string_to_time(string) 110 113 return string unless string.is_a?(String) 111 time_array = ParseDate.parsedate(string)[0.. 5]114 time_array = ParseDate.parsedate(string)[0..6] 112 115 # treat 0000-00-00 00:00:00 as nil 113 116 Time.send(Base.default_timezone, *time_array) rescue nil 114 117 end … … 141 144 :integer 142 145 when /float|double|decimal|numeric/i 143 146 :float 147 when /datetime.with.timezone/i 148 :datetime_with_timezone 144 149 when /datetime/i 145 150 :datetime 146 151 when /timestamp/i … … 207 212 # The +type+ parameter must be one of the following values: 208 213 # <tt>:primary_key</tt>, <tt>:string</tt>, <tt>:text</tt>, 209 214 # <tt>:integer</tt>, <tt>:float</tt>, <tt>:datetime</tt>, 210 # <tt>:timestamp</tt>, <tt>:time</tt>, <tt>:date</tt>, 211 # <tt>:binary</tt>, <tt>:boolean</tt>. 215 # <tt>:datetime_with_timezone</tt>, <tt>:timestamp</tt>, 216 # <tt>:time</tt>, <tt>:date</tt>, <tt>:binary</tt>, 217 # <tt>:boolean</tt>. 212 218 # 213 219 # Available options are (none of these exists by default): 214 220 # * <tt>:limit</tt>: -
active_record/connection_adapters/postgresql_adapter.rb
old new 89 89 :integer => { :name => "integer" }, 90 90 :float => { :name => "float" }, 91 91 :datetime => { :name => "timestamp" }, 92 :datetime_with_timezone => { :name => "timestamp with timezone" }, 92 93 :timestamp => { :name => "timestamp" }, 93 94 :time => { :name => "time" }, 94 95 :date => { :name => "date" }, … … 457 458 def translate_field_type(field_type) 458 459 # Match the beginning of field_type since it may have a size constraint on the end. 459 460 case field_type 461 when /^timestamp with time zone/i then 'datetime_with_timezone' 460 462 when /^timestamp/i then 'datetime' 461 463 when /^real|^money/i then 'float' 462 464 when /^interval/i then 'string' -
active_record/migration.rb
old new 63 63 # * <tt>drop_table(name)</tt>: Drops the table called +name+. 64 64 # * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column to the table called +table_name+ 65 65 # named +column_name+ specified to be one of the following types: 66 # :string, :text, :integer, :float, :datetime, : timestamp, :time, :date, :binary, :boolean. A default value can be specified66 # :string, :text, :integer, :float, :datetime, :datetime_with_timezone, :timestamp, :time, :date, :binary, :boolean. A default value can be specified 67 67 # by passing an +options+ hash like { :default => 11 }. 68 68 # * <tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames a column but keeps the type and content. 69 69 # * <tt>change_column(table_name, column_name, type, options)</tt>: Changes the column to a different type using the same