class Sequel::SQLTime

  1. lib/sequel/sql.rb
Superclass: Time

Time subclass that gets literalized with only the time value, so it operates like a standard SQL time type.

Methods

Public Class

  1. create
  2. date
  3. date

Public Instance

  1. inspect
  2. to_s

Attributes

date [W]

Set the date used for SQLTime instances.

Public Class methods

create (hour, minute, second, usec = 0)

Create a new SQLTime instance given an hour, minute, second, and usec.

[show source]
# File lib/sequel/sql.rb, line 35
def create(hour, minute, second, usec = 0)
  t = date
  meth = Sequel.application_timezone == :utc ? :utc : :local
  public_send(meth, t.year, t.month, t.day, hour, minute, second, usec)
end
date ()

use the date explicitly set, or the current date if there is not a date set.

[show source]
# File lib/sequel/sql.rb, line 30
def date
  @date || now
end

Public Instance methods

inspect ()

Show that this is an SQLTime, and the time represented

[show source]
# File lib/sequel/sql.rb, line 43
def inspect
 "#<#{self.class} #{to_s}>"
end
to_s (*args)

Return a string in HH:MM:SS format representing the time.

[show source]
# File lib/sequel/sql.rb, line 48
def to_s(*args)
  if args.empty?
    strftime('%H:%M:%S')
  else
    # Superclass may have defined a method that takes a format string,
    # and we shouldn't override in that case.
    super
  end
end