Class: PG::TextDecoder::Timestamp
- Inherits:
-
SimpleDecoder
- Object
- Coder
- SimpleCoder
- SimpleDecoder
- PG::TextDecoder::Timestamp
- Defined in:
- ext/pg_text_decoder.c
Overview
This is a decoder class for conversion of PostgreSQL text timestamps to Ruby Time objects.
The following flags can be used to specify time interpretation when no timezone is given:
-
PG::Coder::TIMESTAMP_DB_UTC
: Interpret timestamp as UTC time (default) -
PG::Coder::TIMESTAMP_DB_LOCAL
: Interpret timestamp as local time -
PG::Coder::TIMESTAMP_APP_UTC
: Return timestamp as UTC time (default) -
PG::Coder::TIMESTAMP_APP_LOCAL
: Return timestamp as local time
Example:
deco = PG::TextDecoder::Timestamp.new(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL)
deco.decode("2000-01-01 00:00:00") # => 2000-01-01 01:00:00 +0100
deco.decode("2000-01-01 00:00:00.123-06") # => 2000-01-01 00:00:00 -0600
Direct Known Subclasses
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
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