Last active
August 29, 2015 14:11
-
-
Save doug7410/ab900c18319e4ee1ac4e to your computer and use it in GitHub Desktop.
method for calculating time, used in https://github.com/doug7410/punch-clock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def total_time_on_job | |
total = 0 | |
self.punches.each do |punch| | |
if punch.punch_out | |
punch_in_time = punch.created_at | |
punch_out_time = punch.punch_out | |
total_time = punch_out_time - punch_in_time | |
total += total_time | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment