Class: DB::Postgres::Native::Types::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/db/postgres/native/types.rb

Overview

A date type converter.

Instance Method Summary collapse

Instance Method Details

#nameObject

Get the SQL type name for date.



156
157
158
# File 'lib/db/postgres/native/types.rb', line 156

def name
	"DATE"
end

#parse(string) ⇒ Object

Parse a date value from the database.



163
164
165
166
167
168
169
# File 'lib/db/postgres/native/types.rb', line 163

def parse(string)
	if string
		parts = string.split(/[\-\s:]/)
		
		return Time.utc(*parts)
	end
end