change(options)
public
Returns a new Time where one or more of the
elements have been changed according to the options parameter. The
time options (hour, minute, sec, usec) reset cascadingly, so if only the
hour is passed, then minute, sec, and usec is set to 0. If the hour and
minute is passed, then sec and usec is set to 0.
Show source
def change(options)
::Time.send(
self.utc? ? :utc : :local,
options[:year] || self.year,
options[:month] || self.month,
options[:mday] || self.mday,
options[:hour] || self.hour,
options[:min] || (options[:hour] ? 0 : self.min),
options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec),
options[:usec] || ((options[:hour] || options[:min] || options[:sec]) ? 0 : self.usec)
)
end