Module: Cda::ValueCoercer
Instance Method Summary collapse
- #date_time_to_string(value) ⇒ Object
- #date_to_string(value) ⇒ Object
- #string_to_time(value) ⇒ Object
Instance Method Details
#date_time_to_string(value) ⇒ Object
9 10 11 |
# 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) ⇒ Object
5 6 7 |
# File 'lib/cda/value_coercer.rb', line 5 def date_to_string(value) value.strftime('%Y%m%d') end |
#string_to_time(value) ⇒ Object
13 14 15 16 17 18 19 |
# 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 |