PG::BinaryEncoder::

Timestamp class

This is a encoder class for conversion of Ruby Time objects to PostgreSQL binary timestamps.

The following flags can be used to specify timezone interpretation:

  • PG::Coder::TIMESTAMP_DB_UTC : Send timestamp as UTC time (default)

  • PG::Coder::TIMESTAMP_DB_LOCAL : Send timestamp as local time (slower)

Example:

enco = PG::BinaryEncoder::Timestamp.new(flags: PG::Coder::TIMESTAMP_DB_UTC)
enco.encode(Time.utc(2000, 1, 1))  # => "\x00\x00\x00\x00\x00\x00\x00\x00"

String values are expected to contain a binary data with a length of 8 byte.