
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 0.66 KB | hits: 7 | expires: Never
ruby-1.9.2-p180 :001 > p = Project.find(1)
Project Load (0.6ms) SELECT `projects`.* FROM `projects` WHERE `projects`.`id` = 1 LIMIT 1
=> #<Project id: 1, name: "The First One", startDate: "2011-06-01", endDate: "2011-06-26", created_at: "2011-06-25 17:54:48", updated_at: "2011-06-26 12:33:33", pourcentDate: 102>
ruby-1.9.2-p180 :002 > timeTotal = p.endDate - p.startDate
=> (25/1)
ruby-1.9.2-p180 :004 > timeUsed = DateTime.now - p.startDate
=> (183782028643/7200000000)
ruby-1.9.2-p180 :005 > puts ((timeUsed / timeTotal) * 100)
183782028643/1800000000
=> nil
ruby-1.9.2-p180 :006 > puts ((timeUsed / timeTotal) * 100).to_i
102
=> nil