Class: DBI::Time

Inherits:
Object
  • Object
show all
Defined in:
lib/dbi/utils/time.rb

Overview

Represents a Time

DEPRECATED: Please use a regular Time or DateTime object.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) hour

Returns the value of attribute hour



7
8
9
# File 'lib/dbi/utils/time.rb', line 7

def hour
  @hour
end

- (Object) minute Also known as: min

Returns the value of attribute minute



7
8
9
# File 'lib/dbi/utils/time.rb', line 7

def minute
  @minute
end

- (Object) second Also known as: sec

Returns the value of attribute second



7
8
9
# File 'lib/dbi/utils/time.rb', line 7

def second
  @second
end

Instance Method Details

- (Object) to_s

Returns a DBI::Time object as a string in HH:MM:SS format.



48
49
50
# File 'lib/dbi/utils/time.rb', line 48

def to_s
   sprintf("%02d:%02d:%02d", @hour, @minute, @second)
end

- (Object) to_time

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.



38
39
40
41
42
43
44
45
# File 'lib/dbi/utils/time.rb', line 38

def to_time
   if @original_time
      @original_time
   else
      t = ::Time.now
      ::Time.local(t.year, t.month, t.day, @hour, @minute, @second)
   end
end