Module: ActiveScaffold::Bridges::DatePicker::Finder
- Defined in:
- lib/active_scaffold/bridges/date_picker/ext.rb
Instance Method Summary collapse
- #datetime_column_date?(column) ⇒ Boolean
- #datetime_conversion_for_condition(column) ⇒ Object
- #format_for_date(column, value, ui_name, ui_options) ⇒ Object
- #format_for_datetime(column, value, ui_name, ui_options) ⇒ Object
Instance Method Details
#datetime_column_date?(column) ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/active_scaffold/bridges/date_picker/ext.rb', line 29 def datetime_column_date?(column) if %i[date_picker datetime_picker].include? column.search_ui column.search_ui == :date_picker else super end end |
#datetime_conversion_for_condition(column) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/active_scaffold/bridges/date_picker/ext.rb', line 21 def datetime_conversion_for_condition(column) if column.search_ui == :date_picker :to_date else super end end |
#format_for_date(column, value, ui_name, ui_options) ⇒ Object
37 38 39 40 |
# File 'lib/active_scaffold/bridges/date_picker/ext.rb', line 37 def format_for_date(column, value, ui_name, ) = .reverse_merge(format: :default) if ui_name == :date_picker super end |
#format_for_datetime(column, value, ui_name, ui_options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/active_scaffold/bridges/date_picker/ext.rb', line 42 def format_for_datetime(column, value, ui_name, ) format = I18n.t "time.formats.#{[:format] || :picker}", default: '' if ui_name == :datetime_picker return super if format.blank? parts = Date._parse(value) [[:hour, '%H'], [:min, ':%M'], [:sec, ':%S']].each do |part, f| format.gsub!(f, '') if parts[part].blank? end format += ' %z' if parts[:offset].present? && format !~ /%z/i format.gsub!(/.*(?=%H)/, '') if !parts[:year] && !parts[:month] && !parts[:mday] [format, parts[:offset]] end |