Patch #41954 » 0004-Support-time-offset-for-datetime-column-value.patch
| lib/tasks/extract_fixtures.rake | ||
|---|---|---|
|
task :extract_fixtures => :environment do
|
||
|
dir = ENV['DIR'] || './tmp/fixtures'
|
||
|
time_offset = ENV['TIME_OFFSET'] || ''
|
||
|
FileUtils.mkdir_p(dir)
|
||
|
if time_offset.present? && !time_offset.match?(/^([+-](0[0-9]|1[0-4]):[0-5][0-9])$/)
|
||
|
abort("Invalid TIME_OFFSET format. Use +HH:MM or -HH:MM (e.g. +09:00)")
|
||
|
end
|
||
|
skip_tables = ["schema_migrations", "ar_internal_metadata"]
|
||
|
ActiveRecord::Base.establish_connection
|
||
| ... | ... | |
|
if record[col.name]
|
||
|
record[col.name] = ActiveRecord::Type.lookup(col.type).deserialize(record[col.name])
|
||
|
if col.type == :datetime && record[col.name].is_a?(Time)
|
||
|
record[col.name] = record[col.name].getutc
|
||
|
if time_offset.present?
|
||
|
record[col.name] = record[col.name].localtime(time_offset)
|
||
|
else
|
||
|
record[col.name] = record[col.name].getutc
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||