class Innodb::DataType::DateType

Attributes

name[R]
width[R]

Public Class Methods

new(base_type, modifiers, properties) click to toggle source
# File lib/innodb/data_type.rb, line 292
def initialize(base_type, modifiers, properties)
  @width = 3
  @name = Innodb::DataType.make_name(base_type, modifiers, properties)
end

Public Instance Methods

value(data) click to toggle source
# File lib/innodb/data_type.rb, line 297
def value(data)
  date = BinData::Int24be.read(data) ^ (-1 << 23)
  day = date & 0x1f
  month = (date >> 5) & 0xf
  year = date >> 9
  "%04d-%02d-%02d" % [year, month, day]
end