Class: Innodb::DataType::TimestampType
- Inherits:
-
Object
- Object
- Innodb::DataType::TimestampType
- Defined in:
- lib/innodb/data_type.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(base_type, modifiers, properties) ⇒ TimestampType
constructor
A new instance of TimestampType.
-
#value(data) ⇒ Object
Returns the UTC timestamp as a value in ‘YYYY-MM-DD HH:MM:SS’ format.
Constructor Details
#initialize(base_type, modifiers, properties) ⇒ TimestampType
Returns a new instance of TimestampType.
308 309 310 311 |
# File 'lib/innodb/data_type.rb', line 308 def initialize(base_type, modifiers, properties) @width = 4 @name = Innodb::DataType.make_name(base_type, modifiers, properties) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
306 307 308 |
# File 'lib/innodb/data_type.rb', line 306 def name @name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
306 307 308 |
# File 'lib/innodb/data_type.rb', line 306 def width @width end |
Instance Method Details
#value(data) ⇒ Object
Returns the UTC timestamp as a value in ‘YYYY-MM-DD HH:MM:SS’ format.
314 315 316 317 318 |
# File 'lib/innodb/data_type.rb', line 314 def value(data) = BinData::Uint32be.read(data) return "0000-00-00 00:00:00" if .zero? DateTime.strptime(.to_s, '%s').strftime "%Y-%m-%d %H:%M:%S" end |