Class: DBI::DBD::MSSQL::Type::Date

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

Overview

Custom handling for DATE types in MySQL. See DBI::Type for more information.

Class Method Summary collapse

Class Method Details

.parse(obj) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/dbd/mssql/types.rb', line 54

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

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