module Cda::ValueCoercer

Public Instance Methods

date_time_to_string(value) click to toggle source
# File lib/cda/value_coercer.rb, line 9
def date_time_to_string(value)
  value.strftime('%Y%m%d%H%M%S%z')
end
date_to_string(value) click to toggle source
# File lib/cda/value_coercer.rb, line 5
def date_to_string(value)
  value.strftime('%Y%m%d')
end
string_to_time(value) click to toggle source
# File lib/cda/value_coercer.rb, line 13
def string_to_time(value)
  return if value.blank?
  DateTime.strptime(value, '%Y%m%d%H%M%S%z') rescue
    Date.strptime(value, '%Y%m%d') rescue
      Date.strptime(value, '%Y%m') rescue
        Date.strptime(value, '%Y')
end