Guest User

Untitled

a guest
Jan 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class Log < ActiveRecord::Base
  2. def self.calculate_time(log)
  3. @result = Time.at(log.updated_at - log.created_at).gmtime.strftime('%R:%S')
  4. end
  5.  
  6. def self.calculate_all_time(username)
  7. @log = Log.find_all_by_username(username)
  8. seconds = 0
  9. @log.each do |f|
  10. seconds += (f.updated_at - f.created_at)
  11. end
  12. Time.at(seconds).gmtime.strftime('%R:%S')
  13. end
  14. end
Add Comment
Please, Sign In to add comment