Class: Attrio::Types::Time

Inherits:
Base show all
Defined in:
lib/attrio/types/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/time.rb', line 6

def self.typecast(value, options = {})
  begin
    options[:format].present? ? ::Time.strptime(value.to_s, options[:format]) : ::Time.parse(value.to_s)
  rescue ArgumentError => e
    nil
  end      
end

.typecasted?(value, options = {}) ⇒ Boolean

Returns:



14
15
16
# File 'lib/attrio/types/time.rb', line 14

def self.typecasted?(value, options = {})
  value.is_a? ::Time
end