Class: Innodb::DataType::DateType
- Inherits:
-
Object
- Object
- Innodb::DataType::DateType
- 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) ⇒ DateType
constructor
A new instance of DateType.
- #value(data) ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
289 290 291 |
# File 'lib/innodb/data_type.rb', line 289 def name @name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
290 291 292 |
# File 'lib/innodb/data_type.rb', line 290 def width @width end |
Instance Method Details
#value(data) ⇒ Object
297 298 299 300 301 302 303 |
# 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 |