Module: ActiveScaffold::Bridges::DatePickerBridge::DatepickerColumnHelpers

Defined in:
lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb

Instance Method Summary collapse

Instance Method Details

#datepicker_format_options(column, format, options) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb', line 161

def datepicker_format_options(column, format, options)
  if column.form_ui == :date_picker
    js_format = to_datepicker_format(I18n.translate!("date.formats.#{format}"))
    options['date:dateFormat'] = js_format unless js_format.nil?
  else
    rails_time_format = I18n.translate!("time.formats.#{format}")
    date_format, time_format = datepicker_split_datetime_format(self.to_datepicker_format(rails_time_format))
    options['date:dateFormat'] = date_format unless date_format.nil?
    unless time_format.nil?
      options['time:timeFormat'] = time_format
      options['time:ampm'] = true if rails_time_format.include?('%I')
    end
  end unless format == :default
end

#datepicker_split_datetime_format(datetime_format) ⇒ Object



153
154
155
# File 'lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb', line 153

def datepicker_split_datetime_format(datetime_format)
  ActiveScaffold::Bridges::DatePickerBridge.split_datetime_format(datetime_format)
end

#to_datepicker_format(rails_format) ⇒ Object



157
158
159
# File 'lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb', line 157

def to_datepicker_format(rails_format)
  ActiveScaffold::Bridges::DatePickerBridge.to_datepicker_format(rails_format)
end