Class: RubyVolt::DataType::Timestamp
- Inherits:
-
Long
- Object
- RubyVolt::DataType
- Basic
- FixedSize
- IntegerType
- Long
- RubyVolt::DataType::Timestamp
- Defined in:
- lib/ruby_volt/data_type/basic/fixed_size/timestamp.rb
Constant Summary
Constants inherited from Long
Long::DIRECTIVE, Long::LENGTH, Long::NULL_INDICATOR
Class Method Summary collapse
Methods inherited from Basic
Methods inherited from RubyVolt::DataType
classifyDataType, testpacking, voltDataType
Class Method Details
.pack(val) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/ruby_volt/data_type/basic/fixed_size/timestamp.rb', line 6 def pack(val) # All dates are represented on the wire as Long values. This signed number represents the number of microseconds before or after Jan. 1 1970 00:00:00 GMT, the Unix epoch. Note that the units are microseconds, not milliseconds. val = case val when ::Integer then val when ::Time then val.to_i*1000000 + val.usec # Microseconds end super(val) end |
.unpack(bytes) ⇒ Object
15 16 17 18 19 |
# File 'lib/ruby_volt/data_type/basic/fixed_size/timestamp.rb', line 15 def unpack(bytes) if unpacked = super(bytes) Time.at(unpacked/1000000.to_f) # Microseconds end end |