Changes in new versions / Ruby 3.1

# requires Ruby 3.1 or newer

now = Time.new(202161)

# *** before: ***
if (Time.new(2021)..Time.new(2022)).cover?(now)
  puts "within 2021"
end

# *** in version 3.1: ***
case now
in ^(Time.new(2021)..Time.new(2022)) # ^(...) pins any expression, not just a
#variable
  puts "within 2021"
end