module CustomFields::Types::DateTime::Target
Protected Instance Methods
_formatted_date_time_format()
click to toggle source
# File lib/custom_fields/types/date_time.rb, line 89 def _formatted_date_time_format I18n.t('time.formats.default') end
_get_formatted_date_time(name)
click to toggle source
# File lib/custom_fields/types/date_time.rb, line 83 def _get_formatted_date_time(name) send(name.to_sym).strftime(_formatted_date_time_format) rescue StandardError nil end
_set_formatted_date_time(name, value)
click to toggle source
# File lib/custom_fields/types/date_time.rb, line 65 def _set_formatted_date_time(name, value) if value.is_a?(::String) && !value.blank? date_time = ::DateTime._strptime(value, _formatted_date_time_format) if date_time value = ::Time.zone.local(date_time[:year], date_time[:mon], date_time[:mday], date_time[:hour], date_time[:min], date_time[:sec] || 0) # , date_time[:zone] || "") else value = begin ::Time.zone.parse(value) rescue StandardError nil end end end send(:"#{name}=", value) end