class Sequel::SQLTime
Time subclass that gets literalized with only the time value, so it operates like a standard SQL
time type. This type does not support timezones, by design, so it will not work correctly with time with time zone
types.
Attributes
Public Class Methods
Source
# File lib/sequel/sql.rb 52 def create(hour, minute, second, usec = 0) 53 t = date 54 meth = Sequel.application_timezone == :utc ? :utc : :local 55 public_send(meth, t.year, t.month, t.day, hour, minute, second, usec) 56 end
Create a new SQLTime
instance given an hour, minute, second, and usec.
Source
# File lib/sequel/sql.rb 32 def date 33 @date || now 34 end
Use the date explicitly set, or the current date if there is not a date set.
Source
# File lib/sequel/sql.rb 37 def parse(*) 38 t = super 39 40 utc = Sequel.application_timezone == :utc 41 d = @date 42 if d || utc 43 meth = utc ? :utc : :local 44 d ||= t 45 t = public_send(meth, d.year, d.month, d.day, t.hour, t.min, t.sec, t.usec) 46 end 47 48 t 49 end
Set the correct date and timezone when parsing times.
Calls superclass method
Public Instance Methods
Source
# File lib/sequel/sql.rb 60 def inspect 61 "#<#{self.class} #{to_s}>" 62 end
Show that this is an SQLTime
, and the time represented
Source
# File lib/sequel/sql.rb 65 def to_s(*args) 66 if args.empty? 67 strftime('%H:%M:%S') 68 else 69 # Superclass may have defined a method that takes a format string, 70 # and we shouldn't override in that case. 71 super 72 end 73 end
Return a string in HH:MM:SS format representing the time.
Calls superclass method