class Mysql::Time

@!visibility public @!attribute [rw] year

@return [Integer]

@!attribute [rw] month

@return [Integer]

@!attribute [rw] day

@return [Integer]

@!attribute [rw] hour

@return [Integer]

@!attribute [rw] minute

@return [Integer]

@!attribute [rw] second

@return [Integer]

@!attribute [rw] neg

@return [Boolean] negative flag

@!attribute [rw] second_part

@return [Integer]

Attributes

day[RW]
hour[RW]
min[RW]
minute[RW]
mon[RW]
month[RW]
neg[RW]
sec[RW]
second[RW]
second_part[RW]
year[RW]

Public Class Methods

new(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) click to toggle source

@param [Integer] year @param [Integer] month @param [Integer] day @param [Integer] hour @param [Integer] minute @param [Integer] second @param [Boolean] neg negative flag @param [Integer] second_part

# File lib/vendor/mysql.rb, line 1046
def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0)
  @date_flag = !(hour && minute && second)
  @year, @month, @day, @hour, @minute, @second, @neg, @second_part =
    year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i
end

Public Instance Methods

==(other) click to toggle source

@private

# File lib/vendor/mysql.rb, line 1057
def ==(other)
  other.is_a?(Mysql::Time) &&
    @year == other.year && @month == other.month && @day == other.day &&
    @hour == other.hour && @minute == other.minute && @second == other.second &&
    @neg == neg && @second_part == other.second_part
end
eql?(other) click to toggle source

@private

# File lib/vendor/mysql.rb, line 1065
def eql?(other)
  self == other
end
inspect() click to toggle source

@private

# File lib/vendor/mysql.rb, line 1087
def inspect
  sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec
end
to_i() click to toggle source

@return [Integer] yyyymmddHHMMSS

# File lib/vendor/mysql.rb, line 1082
def to_i
  sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i
end
to_s() click to toggle source

@return [String] “yyyy-mm-dd HH:MM:SS”

# File lib/vendor/mysql.rb, line 1070
def to_s
  if @date_flag
    sprintf "%04d-%02d-%02d", year, mon, day
  elsif year == 0 and mon == 0 and day == 0
    h = neg ? hour * -1 : hour
    sprintf "%02d:%02d:%02d", h, min, sec
  else
    sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec
  end
end