Class: PG::TextDecoder::TimestampWithTimeZone

Inherits:
SimpleDecoder
  • Object
show all
Defined in:
lib/pg/text_decoder.rb

Constant Summary collapse

ISO_DATETIME_WITH_TIMEZONE =
/\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?([-\+]\d\d)\z/

Instance Method Summary collapse

Instance Method Details

#decode(string, tuple = nil, field = nil) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/pg/text_decoder.rb', line 32

def decode(string, tuple=nil, field=nil)
	if string =~ ISO_DATETIME_WITH_TIMEZONE
		Time.new $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, "#{$6}#{$7}".to_r, "#{$8}:00"
	else
		string
	end
end