Created
November 26, 2008 03:23
-
-
Save renaehodgkins/29258 to your computer and use it in GitHub Desktop.
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 time_get | |
puts "Please hit Enter to start time tracking" | |
if gets.chomp == "" | |
Time.now | |
else | |
time_get | |
end | |
end | |
def time_stop | |
puts "Please hit Enter again to stop time tracking" | |
if gets.chomp == "" | |
Time.now | |
else | |
time_stop | |
end | |
end | |
def time_track | |
start_time = time_get | |
puts "Time tracking started at #{start_time}" | |
end_time = time_stop | |
puts "Time tracking ended at #{end_time}" | |
end_time.to_i - start_time.to_i | |
end | |
time = time_track | |
# omg hack - http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/170729 | |
puts [time/3600, time/60 % 60, time % 60].collect {|t| t.to_s.rjust(2, '0')}.join(':') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment