Skip to content

Commit

Permalink
Override Psych yaml format_time method
Browse files Browse the repository at this point in the history
  • Loading branch information
sanak committed Dec 11, 2024
1 parent 6608734 commit 2e4c0cb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/tasks/extract_fixtures.rake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override.'

module Psych
module Visitors
class YAMLTree
# Override default time format
# https://github.com/ruby/ruby/blob/v3_3_6/ext/psych/lib/psych/visitors/yaml_tree.rb#L484-L490
def format_time time, utc = time.utc?
if utc
time.strftime("%Y-%m-%d %H:%M:%S")
else
time.strftime("%Y-%m-%d %H:%M:%S %:z")
end
end
end
end
end

task :extract_fixtures => :environment do
dir = ENV['DIR'] || './tmp/fixtures'
time_offset = ENV['TIME_OFFSET'] || ''
Expand Down

0 comments on commit 2e4c0cb

Please sign in to comment.