class MessagePack::Timestamp

def self.from_msgpack_ext(data)

def self.from_msgpack_ext(data)
  case data.length
  when 4
    # timestamp32 (sec: uint32be)
    sec, = data.unpack('L>')
    new(sec, 0)
  when 8
    # timestamp64 (nsec: uint30be, sec: uint34be)
    n, s = data.unpack('L>2')
    sec = ((n & 0b11) << 32) | s
    nsec = n >> 2
    new(sec, nsec)
  when 12
    # timestam96 (nsec: uint32be, sec: int64be)
    nsec, sec = data.unpack('L>q>')
    new(sec, nsec)
  else
    raise MalformedFormatError, "Invalid timestamp data size: #{data.length}"
  end
end