class Innodb::DataType::TimestampType

Attributes

name[R]
width[R]

Public Class Methods

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

Public Instance Methods

value(data) click to toggle source

Returns the UTC timestamp as a value in ‘YYYY-MM-DD HH:MM:SS’ format.

# File lib/innodb/data_type.rb, line 339
def value(data)
  timestamp = BinData::Uint32be.read(data)
  return "0000-00-00 00:00:00" if timestamp.zero?

  DateTime.strptime(timestamp.to_s, "%s").strftime "%Y-%m-%d %H:%M:%S"
end