Sha256: 1b5cf3a0ebafb1bcf1951f0b06c2cddb5885fb8902a70fa70e4ebd65717dc82a

Contents?: true

Size: 488 Bytes

Versions: 13

Compression:

Stored size: 488 Bytes

Contents

# -*- ruby -*-
# frozen_string_literal: true

require 'date'

module PG
	module TextDecoder
		# This is a decoder class for conversion of PostgreSQL date type to Ruby Date values.
		#
		# As soon as this class is used, it requires the ruby standard library 'date'.
		class Date < SimpleDecoder
			def decode(string, tuple=nil, field=nil)
				if string =~ /\A(\d{4})-(\d\d)-(\d\d)\z/
					::Date.new $1.to_i, $2.to_i, $3.to_i
				else
					string
				end
			end
		end
	end
end # module PG

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pg-1.6.0.rc1-x86_64-linux lib/pg/text_decoder/date.rb
pg-1.6.0.rc1-x86-mingw32 lib/pg/text_decoder/date.rb
pg-1.6.0.rc1-x64-mingw32 lib/pg/text_decoder/date.rb
pg-1.6.0.rc1-x64-mingw-ucrt lib/pg/text_decoder/date.rb
pg-1.6.0.rc1 lib/pg/text_decoder/date.rb
pg-1.5.9-x86-mingw32 lib/pg/text_decoder/date.rb
pg-1.5.9-x64-mingw32 lib/pg/text_decoder/date.rb
pg-1.5.9-x64-mingw-ucrt lib/pg/text_decoder/date.rb
pg-1.5.9 lib/pg/text_decoder/date.rb
pg-1.5.8-x64-mingw32 lib/pg/text_decoder/date.rb
pg-1.5.8-x64-mingw-ucrt lib/pg/text_decoder/date.rb
pg-1.5.8-x86-mingw32 lib/pg/text_decoder/date.rb
pg-1.5.8 lib/pg/text_decoder/date.rb