Time の一部を自由自在に改変したい

time.change(hour: 23, min: 59, sec: 59)
#=> Wed, 01 Jan 2014 23:59:59 JST +09:00

オプションで指定できるのは、 :year, :month, :day, :hour, :min, :sec, :usec だそうです。

> Time.current
=> Sat, 27 Feb 2021 01:51:54 UTC +00:00

> Time.current.change(year: 2020)
=> Thu, 27 Feb 2020 01:52:00 UTC +00:00

> Time.current.change(hour: 1)
=> Sat, 27 Feb 2021 01:00:00 UTC +00:00
> Time.current.change(min: 1)
=> Sat, 27 Feb 2021 01:01:00 UTC +00:00
> Time.current.change(sec: 1)
=> Sat, 27 Feb 2021 01:52:01 UTC +00:00

Time | RailsDoc(β)