Created
February 28, 2011 19:32
-
-
Save mysteriouspants/847868 to your computer and use it in GitHub Desktop.
Short Ruby script written for the purpose of automating the process of computing the total time worked each week on my archaic paper-based timecard.
This file contains hidden or 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
#!ruby | |
require 'highline/import' | |
require 'date' | |
total_time = nil | |
begin_time = nil | |
end_time = nil | |
while true | |
begin_time = DateTime.parse '2011-01-01 ' + ask('begining time (HH:MM)') + ':00' | |
end_time = DateTime.parse '2011-01-01 ' + ask('end time (HH:MM, 4:00 PM is 16:00)') + ':00' | |
total_time = total_time + (end_time - begin_time) unless total_time == nil | |
total_time = end_time - begin_time if total_time == nil | |
puts 'Total time is ' + (total_time.to_f * 24.0).to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment