From 16908043f90dc32654eb01f892c120e242ac889e Mon Sep 17 00:00:00 2001 From: Ko Nagase Date: Mon, 9 Dec 2024 17:12:10 +0900 Subject: [PATCH 5/5] Override Psych yaml format_time method --- lib/tasks/extract_fixtures.rake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/tasks/extract_fixtures.rake b/lib/tasks/extract_fixtures.rake index ea757ae7c..12636ced0 100644 --- a/lib/tasks/extract_fixtures.rake +++ b/lib/tasks/extract_fixtures.rake @@ -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'] || '' -- 2.47.1