class Innodb::DataType::DatetimeType
Attributes
name[R]
width[R]
Public Class Methods
new(base_type, modifiers, properties)
click to toggle source
# File lib/innodb/data_type.rb, line 310 def initialize(base_type, modifiers, properties) @width = 8 @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 315 def value(data) datetime = BinData::Int64be.read(data) ^ (-1 << 63) date = datetime / 1_000_000 year = date / 10_000 month = (date / 100) % 100 day = date % 100 time = datetime - (date * 1_000_000) hour = time / 10_000 min = (time / 100) % 100 sec = time % 100 "%04d-%02d-%02d %02d:%02d:%02d" % [year, month, day, hour, min, sec] end