Class: PG::TextDecoder::TimestampWithoutTimeZone

Inherits:
SimpleDecoder
  • Object
show all
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 Method Summary collapse

Instance Method Details

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



20
21
22
23
24
25
26
# File 'lib/pg/text_decoder.rb', line 20

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