3
# Returns a new Time where one or more of the elements
4
# have been changed according to the +options+ parameter.
5
# The time options (hour, minute, sec, usec) reset
6
# cascadingly, so if only the hour is passed, then
7
# minute, sec, and usec is set to 0. If the hour and
8
# minute is passed, then sec and usec is set to 0.
11
# t1.ctime #=> "Wed Dec 31 21:46:40 1969"
13
# t2 = t1.change(:hour => 11)
14
# t2.ctime #=> "Wed Dec 31 11:00:00 1969"
17
opts=options; #{}; options.each_pair{ |k,v| opts[k] = v.to_i }
19
self.utc? ? :utc : :local,
20
opts[:year] || self.year,
21
opts[:month] || self.month,
22
opts[:day] || self.day,
23
opts[:hour] || self.hour,
24
opts[:min] || (opts[:hour] ? 0 : self.min),
25
opts[:sec] || ((opts[:hour] || opts[:min]) ? 0 : self.sec),
26
opts[:usec] || ((opts[:hour] || opts[:min] || opts[:sec]) ? 0 : self.usec)
34
# self.utc? ? :utc_time : :local_time,
35
# options[:year] || self.year,
36
# options[:month] || self.month,
37
# options[:day] || self.day,
38
# options[:hour] || self.hour,
39
# options[:min] || (options[:hour] ? 0 : self.min),
40
# options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec),
41
# options[:usec] || ((options[:hour] || options[:min] || options[:sec]) ? 0 : self.usec)