Sha256: c91b6d3ce8c83b114fb7d2528ae983b08b5537013b25469d218736e84c797a2f

Contents?: true

Size: 887 Bytes

Versions: 17

Compression:

Stored size: 887 Bytes

Contents

#!/usr/bin/env ruby

require 'json'

module PG
	module TextEncoder
		class Date < SimpleEncoder
			STRFTIME_ISO_DATE = "%Y-%m-%d".freeze
			def encode(value)
				value.respond_to?(:strftime) ? value.strftime(STRFTIME_ISO_DATE) : value
			end
		end

		class TimestampWithoutTimeZone < SimpleEncoder
			STRFTIME_ISO_DATETIME_WITHOUT_TIMEZONE = "%Y-%m-%d %H:%M:%S.%N".freeze
			def encode(value)
				value.respond_to?(:strftime) ? value.strftime(STRFTIME_ISO_DATETIME_WITHOUT_TIMEZONE) : value
			end
		end

		class TimestampWithTimeZone < SimpleEncoder
			STRFTIME_ISO_DATETIME_WITH_TIMEZONE = "%Y-%m-%d %H:%M:%S.%N %:z".freeze
			def encode(value)
				value.respond_to?(:strftime) ? value.strftime(STRFTIME_ISO_DATETIME_WITH_TIMEZONE) : value
			end
		end

		class JSON < SimpleEncoder
			def encode(value)
				::JSON.generate(value, quirks_mode: true)
			end
		end
	end
end # module PG

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
pg-1.0.0-x64-mingw32 lib/pg/text_encoder.rb
pg-1.0.0-x86-mingw32 lib/pg/text_encoder.rb
pg-1.0.0 lib/pg/text_encoder.rb
pg-0.21.0-x64-mingw32 lib/pg/text_encoder.rb
pg-0.21.0-x86-mingw32 lib/pg/text_encoder.rb
pg-0.21.0 lib/pg/text_encoder.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/pg-0.20.0/lib/pg/text_encoder.rb
pg-0.20.0-x86-mingw32 lib/pg/text_encoder.rb
pg-0.20.0-x64-mingw32 lib/pg/text_encoder.rb
pg-0.20.0 lib/pg/text_encoder.rb
pg-0.19.1.pre20170124220800-x64-mingw32 lib/pg/text_encoder.rb
pg-0.19.1.pre20170124220800-x86-mingw32 lib/pg/text_encoder.rb
pg-0.19.1.pre20170124220800 lib/pg/text_encoder.rb
pg-0.19.1.pre20170115074000-x64-mingw32 lib/pg/text_encoder.rb
pg-0.19.1.pre20170115074000-x86-mingw32 lib/pg/text_encoder.rb
pg-0.19.1.pre20170115074000 lib/pg/text_encoder.rb
pg-0.19.0.pre20170115074000 lib/pg/text_encoder.rb