app/controllers/anoubis/data/convert.rb
##
# Convert value from database to table view for datetime type
Convert value from database to table view for datetime type
Convert value from database to table view for datetime type
def convert_db_to_view_value_datetime(key, value)
        field = self.etc.data.fields[key]
        if (value.class == Date) || (value.class == ActiveSupport::TimeWithZone)
          begin
            new_value = convert_datetime_to_string value, field.format
            if %w[month date].include? field.format
              raw_value = value.year.to_s + '-' + ('%02d' % value.month) + '-' + ('%02d' % value.day)
            else
              raw_value = value.iso8601(2)[0..18]
            end
          rescue StandardError => e
            new_value = field.error_text
          end
        else
          new_value = '';
        end
        case self.etc.action
        when 'new', 'edit'
          return { key => raw_value, format('%s_view', key).to_sym => new_value }
        end
        return { key => new_value, format('%s_raw', key).to_sym => value }
      end
def convert_db_to_view_value_datetime ( key , value ) field = self . etc . data . fields [ key ] if ( value . class == Date ) || ( value . class == ActiveSupport :: TimeWithZone ) begin new_value = convert_datetime_to_string value , field . format if %w[ month date ] . include? field . format raw_value = value . year . to_s + '-' + ( '%02d' % value . month ) + '-' + ( '%02d' % value . day ) else raw_value = value . iso8601 ( 2 ) [ 0 .. 18 ] end rescue StandardError => e new_value = field . error_text end else new_value = '' ; end case self . etc . action when 'new' , 'edit' return { key => raw_value , format ( '%s_view' , key ) . to_sym => new_value } end return { key => new_value , format ( '%s_raw' , key ) . to_sym => value } end
Convert value from database to table view for datetime type
Convert value from database to table view for datetime type
#puts key #puts value.class #raw_value = value.year.to_s + '-' + ('%02d' % value.month) + '-' + ('%02d' % value.day) + ' ' + ('%02d' % value.hour) + ':' + ('%02d' % value.min) #puts e
key
<not_specific>
value
<not_specific>