class MessagePack::Timestamp
def self.to_msgpack_ext(sec, nsec)
def self.to_msgpack_ext(sec, nsec) if sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC if nsec === 0 && sec <= TIMESTAMP32_MAX_SEC # timestamp32 = (sec: uint32be) [sec].pack('L>') else # timestamp64 (nsec: uint30be, sec: uint34be) nsec30 = nsec << 2 sec_high2 = sec >> 32 # high 2 bits (`x & 0b11` is redandunt) sec_low32 = sec & 0xffffffff # low 32 bits [nsec30 | sec_high2, sec_low32].pack('L>2') end else # timestamp96 (nsec: uint32be, sec: int64be) [nsec, sec].pack('L>q>') end end