Class: DBI::DBD::MSSQL::Type::Timestamp

Inherits:
Type::Null
  • Object
show all
Defined in:
lib/dbd/mssql/types.rb

Overview

Custom handling for TIMESTAMP and DATETIME types in MySQL. See DBI::Type for more information.

Class Method Summary collapse

Class Method Details

.parse(obj) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dbd/mssql/types.rb', line 28

def self.parse(obj)
    obj = super
    return obj unless obj

    case obj.class
    when ::DateTime
        return obj
    when ::String
        return ::DateTime.strptime(obj, "%Y-%m-%d %H:%M:%S")
    else
        return ::DateTime.parse(obj.to_s)   if obj.respond_to? :to_s
        return ::DateTime.parse(obj.to_str) if obj.respond_to? :to_str
        return obj
    end
end