### Home Classes Methods

### In Files

- lib/dbi/utils/time.rb

### Parent

Object

### Methods

- ::new
- #to_s
- #to_time

### Included Modules

- Deprecated

### Files

- README

### Class/Module Index

Quicksearch

- DBI
- DBI::BaseDatabase
- DBI::BaseDriver
- DBI::BaseStatement
- DBI::Binary
- DBI::ColumnInfo
- DBI::DataError
- DBI::DatabaseError
- DBI::DatabaseHandle
- DBI::Date
- DBI::DriverHandle
- DBI::Error
- DBI::Handle
- DBI::HandleTracer
- DBI::IntegrityError
- DBI::InterfaceError
- DBI::InternalError
- DBI::NotImplementedError
- DBI::NotSupportedError
- DBI::OperationalError
- DBI::ProgrammingError
- DBI::Row
- DBI::SQL
- DBI::SQL::PreparedStatement
- DBI::StatementHandle
- DBI::Time
- DBI::Timestamp
- DBI::Type
- DBI::Type::Boolean
- DBI::Type::Decimal
- DBI::Type::Float
- DBI::Type::Integer
- DBI::Type::Null
- DBI::Type::Timestamp
- DBI::Type::Varchar
- DBI::TypeUtil
- DBI::Utils
- DBI::Utils::ConvParam
- DBI::Utils::TableFormatter
- DBI::Utils::XMLFormatter
- DBI::Warning
- Class

No matching classes.

# DBI::Time

Represents a Time

DEPRECATED: Please use a regular Time or DateTime object.

### Attributes

hour[RW]
min[RW]
min=[RW]
minute[RW]
sec[RW]
sec=[RW]
second[RW]

### Public Class Methods

new(hour=0, minute=0, second=0) click to toggle source

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 17
    def initialize(hour=0, minute=0, second=0)
       case hour
          when ::Time
             @hour, @minute, @second = hour.hour, hour.min, hour.sec
             @original_time = hour
          else
             @hour, @minute, @second = hour, minute, second
       end
    end

### Public Instance Methods

to_s() click to toggle source

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

    # File lib/dbi/utils/time.rb, line 49
    def to_s
       sprintf("%02d:%02d:%02d", @hour, @minute, @second)
    end

to_time() click to toggle source

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 39
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.