Class: PG::TextDecoder::Date

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

Constant Summary collapse

ISO_DATE =
/\A(\d{4})-(\d\d)-(\d\d)\z/

Instance Method Summary collapse

Instance Method Details

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



8
9
10
11
12
13
14
# File 'lib/pg/text_decoder.rb', line 8

def decode(string, tuple=nil, field=nil)
	if string =~ ISO_DATE
		Time.new $1.to_i, $2.to_i, $3.to_i
	else
		string
	end
end