module CustomFields::Types::Date::Target
Protected Instance Methods
_formatted_date_format()
click to toggle source
# File lib/custom_fields/types/date.rb, line 89 def _formatted_date_format I18n.t('date.formats.default') end
_get_formatted_date(name)
click to toggle source
# File lib/custom_fields/types/date.rb, line 83 def _get_formatted_date(name) send(name.to_sym).strftime(_formatted_date_format) rescue StandardError nil end
_set_formatted_date(name, value)
click to toggle source
# File lib/custom_fields/types/date.rb, line 65 def _set_formatted_date(name, value) if value.is_a?(::String) && !value.blank? date = ::Date._strptime(value, _formatted_date_format) value = if date ::Date.new(date[:year], date[:mon], date[:mday]) else begin ::Date.parse(value) rescue StandardError nil end end end send(:"#{name}=", value) end