Class: DB::MariaDB::Native::Types::DateTime
- Inherits:
-
Object
- Object
- DB::MariaDB::Native::Types::DateTime
- Defined in:
- lib/db/mariadb/native/types.rb
Overview
A datetime type converter.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
- #The SQL type name.(SQLtypename.) ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(name = "DATETIME") ⇒ DateTime
constructor
Initialize a datetime type converter.
-
#parse(string) ⇒ Object
Parse a datetime value from the database.
Constructor Details
#initialize(name = "DATETIME") ⇒ DateTime
Initialize a datetime type converter.
132 133 134 |
# File 'lib/db/mariadb/native/types.rb', line 132 def initialize(name = "DATETIME") @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
137 138 139 |
# File 'lib/db/mariadb/native/types.rb', line 137 def name @name end |
#The SQL type name.(SQLtypename.) ⇒ Object (readonly)
137 |
# File 'lib/db/mariadb/native/types.rb', line 137 attr :name |
Instance Method Details
#parse(string) ⇒ Object
Parse a datetime value from the database.
142 143 144 145 146 147 148 |
# File 'lib/db/mariadb/native/types.rb', line 142 def parse(string) if string parts = string.split(/[\-\s:]/) return Time.utc(*parts) end end |