Skip to content

Instantly share code, notes, and snippets.

@kreeger
Created May 11, 2012 18:28
Show Gist options
  • Save kreeger/2661545 to your computer and use it in GitHub Desktop.
Save kreeger/2661545 to your computer and use it in GitHub Desktop.
Calculates the amount of time remaining in a 40 hour work-week
#!/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