Skip to content

Require date and time in files that use iso8601

What does this MR do and why?

require 'date', require 'time' in files that use .iso8601 method on corresponding objects.

This is needed to avoid undefined method error for .iso8601 call.

Example of a failure that caused by this: https://gitlab.com/gitlab-org/gitlab/-/jobs/11545449855#L721

Proof that this fix works from irb:

irb(main):002> Time.now.to_date.iso8601
(irb):2:in `<main>': undefined method `to_date' for an instance of Time (NoMethodError)

Time.now.to_date.iso8601
        ^^^^^^^^
Did you mean?  to_a
	from <internal:kernel>:187:in `loop'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/irb-1.15.1/exe/irb:9:in `<top (required)>'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/lib/ruby/site_ruby/3.3.0/rubygems.rb:319:in `load'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/lib/ruby/site_ruby/3.3.0/rubygems.rb:319:in `activate_and_load_bin_path'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/bin/irb:25:in `<main>'
irb(main):003> require 'date'
=> true
irb(main):004> Time.now.to_date.iso8601
=> "2025-10-07"
irb(main):005> Time.now.utc.iso8601
(irb):5:in `<main>': undefined method `iso8601' for an instance of Time (NoMethodError)

Time.now.utc.iso8601
            ^^^^^^^^
	from <internal:kernel>:187:in `loop'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/irb-1.15.1/exe/irb:9:in `<top (required)>'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/lib/ruby/site_ruby/3.3.0/rubygems.rb:319:in `load'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/lib/ruby/site_ruby/3.3.0/rubygems.rb:319:in `activate_and_load_bin_path'
	from /Users/ievche/.local/share/mise/installs/ruby/3.3.9/bin/irb:25:in `<main>'
irb(main):006> require 'time'
=> true
irb(main):007> Time.now.utc.iso8601

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Ievgen Chernikov

Merge request reports

Loading