Class: PG::BinaryEncoder::Timestamp

Inherits:
SimpleEncoder show all
Defined in:
ext/pg_binary_encoder.c

Overview

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.

Direct Known Subclasses

TimestampLocal, TimestampUtc

Constant Summary

Constants inherited from Coder

Coder::FORMAT_ERROR_MASK, Coder::FORMAT_ERROR_TO_PARTIAL, Coder::FORMAT_ERROR_TO_RAISE, Coder::FORMAT_ERROR_TO_STRING, Coder::TIMESTAMP_APP_LOCAL, Coder::TIMESTAMP_APP_UTC, Coder::TIMESTAMP_DB_LOCAL, Coder::TIMESTAMP_DB_UTC

Instance Attribute Summary

Attributes inherited from Coder

#name

Method Summary

Methods inherited from Coder

#==, #dup, #flags, #flags=, #format, #format=, #initialize, #inspect, #inspect_short, #marshal_dump, #marshal_load, #oid, #oid=, #to_h

Constructor Details

This class inherits a constructor from PG::Coder