Class: PG::TextDecoder::TimestampWithoutTimeZone
- Inherits:
-
SimpleDecoder
- Object
- Coder
- SimpleCoder
- SimpleDecoder
- PG::TextDecoder::TimestampWithoutTimeZone
- Defined in:
- lib/pg/text_decoder.rb
Constant Summary collapse
- ISO_DATETIME_WITHOUT_TIMEZONE =
/\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/
Instance Attribute Summary
Attributes inherited from Coder
Instance Method Summary collapse
Methods inherited from Coder
#==, #dup, #encode, #format, #format=, #initialize, #inspect, #marshal_dump, #marshal_load, #oid, #oid=, #to_h
Constructor Details
This class inherits a constructor from PG::Coder
Instance Method Details
#decode(string, tuple = nil, field = nil) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/pg/text_decoder.rb', line 23 def decode(string, tuple=nil, field=nil) if string =~ ISO_DATETIME_WITHOUT_TIMEZONE Time.new $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, "#{$6}#{$7}".to_r else string end end |