Method: ActiveScaffold::Finder::ClassMethods#format_for_date

Defined in:
lib/active_scaffold/finder.rb

#format_for_date(column, value, format_name = ) ⇒ Object



285
286
287
288
289
290
291
292
# File 'lib/active_scaffold/finder.rb', line 285

def format_for_date(column, value, format_name = column.options[:format])
  if format_name
    format = I18n.t("date.formats.#{format_name}")
    format.gsub!(/%-d|%-m|%_m/) { |s| s.gsub(/[-_]/, '') } # strptime fails with %-d, %-m, %_m
    en_value = I18n.locale == :en ? value : translate_days_and_months(value, format)
  end
  [en_value || value, format]
end