| Class | DBI::Time |
| In: |
lib/dbi/utils/time.rb
|
| Parent: | Object |
| minute | -> | min |
| minute= | -> | min= |
| second | -> | sec |
| second= | -> | sec= |
| hour | [RW] | |
| minute | [RW] | |
| second | [RW] |
DBI::Time.new(hour = 0, minute = 0, second = 0) DBI::Time.new(Time)
Creates and returns a new DBI::Time object. Unlike the Time object in the standard library, accepts an hour, minute and second, or a Time object.
# File lib/dbi/utils/time.rb, line 16
16: def initialize(hour=0, minute=0, second=0)
17: case hour
18: when ::Time
19: @hour, @minute, @second = hour.hour, hour.min, hour.sec
20: @original_time = hour
21: else
22: @hour, @minute, @second = hour, minute, second
23: end
24: end
Returns a new Time object based on the hour, minute and second, using the current year, month and day. If a Time object was passed to the constructor, returns that object instead.
# File lib/dbi/utils/time.rb, line 38
38: def to_time
39: if @original_time
40: @original_time
41: else
42: t = ::Time.now
43: ::Time.local(t.year, t.month, t.day, @hour, @minute, @second)
44: end
45: end