app/controllers/anoubis/data/convert.rb
##
# Convert value from database to edit form for datetime type
# @param key [Symbol] field's identifier
# @param field [Hash] field's options
# @param value [Any] value from database before processing
# @return [Hash] resulting value in format <b>{ key: processed_value }</b>
Convert value from database to edit form for datetime type
Convert value from database to edit form for datetime type
def convert_db_to_table_value_datetime(key, field, value)
        begin
          value = case field[:format]
                  when 'month' then I18n.t('anoubis.months.main')[value.month-1]+' '+value.year.to_s
                  when 'date' then value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s
                  when 'datetime' then value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)
                  else value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)+':'+('%02d' % value.sec)
                  end
        rescue
          value = I18n.t('incorrect_field_format')
        end
        return { key => value }
      end
def convert_db_to_table_value_datetime ( key , field , value ) begin value = case field [ :format ] when 'month' then I18n . t ( 'anoubis.months.main' ) [ value . month - 1 ] + ' ' + value . year . to_s when 'date' then value . day . to_s + ' ' + I18n . t ( 'anoubis.months.second' ) [ value . month - 1 ] + ' ' + value . year . to_s when 'datetime' then value . day . to_s + ' ' + I18n . t ( 'anoubis.months.second' ) [ value . month - 1 ] + ' ' + value . year . to_s + ', ' + value . hour . to_s + ':' + ( '%02d' % value . min ) else value . day . to_s + ' ' + I18n . t ( 'anoubis.months.second' ) [ value . month - 1 ] + ' ' + value . year . to_s + ', ' + value . hour . to_s + ':' + ( '%02d' % value . min ) + ':' + ( '%02d' % value . sec ) end rescue value = I18n . t ( 'incorrect_field_format' ) end return { key => value } end
Convert value from database to edit form for datetime type
Convert value from database to edit form for datetime type
resulting value in format { key: processed_value }
resulting value in format { key : processed_value }
Hash
key
None
field
None
value
value from database before processing
value from database before processing