Created
May 11, 2012 18:28
-
-
Save kreeger/2661545 to your computer and use it in GitHub Desktop.
Calculates the amount of time remaining in a 40 hour work-week
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
#!/usr/bin/env ruby | |
# 4hr HOURS_THIS_WEEK TIME_CLOCKED_IN | |
require 'time' | |
begin | |
week_time = ARGV[0].to_f | |
clock_in = Time.parse(ARGV[1]) | |
rescue Exception => e | |
exit | |
end | |
seconds = (40 - week_time) * 3600 | |
time_left = (Time.mktime(0)+seconds).strftime("%H:%M:%S") | |
out_time = clock_in + seconds | |
puts "Clocked in at #{clock_in.strftime('%l:%M%P')} with #{week_time} hours this week." | |
puts "Time left: #{time_left}." | |
puts "Clockout time: #{out_time.strftime('%l:%M:%S%P')}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment