Class: Attrio::Types::DateTime
- Inherits:
-
Base
show all
- Defined in:
- lib/attrio/types/date_time.rb
Class Method Summary
collapse
Methods inherited from Base
default_reader_aliases, default_writer_aliases
Class Method Details
.typecast(value, options = {}) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/attrio/types/date_time.rb', line 6
def self.typecast(value, options = {})
begin
options[:format].present? ? ::DateTime.strptime(value.to_s, options[:format]) : ::DateTime.parse(value.to_s)
rescue ArgumentError => e
nil
end
end
|
.typecasted?(value, options = {}) ⇒ Boolean
14
15
16
|
# File 'lib/attrio/types/date_time.rb', line 14
def self.typecasted?(value, options = {})
value.is_a? ::DateTime
end
|