module ReportsHelper  
  def time_converter(sec)
    seconds = sec
    string = ''
    if(seconds != '')
      minutes = (seconds/60).round(0);
      hours = (minutes/60).round(0);
      days =(hours/24).round(0);    
      hours = hours-(days*24);
      minutes = minutes-(days*24*60)-(hours*60);
      seconds = seconds-(days*24*60*60)-(hours*60*60)-(minutes*60);    
      if((days).to_i != 0)
        string += days.to_s + 'd' + ' ';
      end
      if((hours).to_i != 0)
        string += hours.to_s + 'hr' + ' ' ;
      end
      if((minutes).to_i != 0)
        string += minutes.to_s + 'm' + ' ';
      end
      if ((seconds).to_i != 0)    
        string +=  seconds.to_s + 's';
      end
     end
     return string;
    end
end