Skip to content

Instantly share code, notes, and snippets.

@qoobaa
Last active December 9, 2015 21:18
Show Gist options
  • Save qoobaa/4329202 to your computer and use it in GitHub Desktop.
Save qoobaa/4329202 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "csv"
time = 0
CSV.foreach(ARGV.first, headers: true) do |row|
puts "#{row["Start date"]} #{row["Duration"]} #{row["Description"]}"
hours, minutes, seconds = row["Duration"].split(":").map(&:to_i)
time += hours * 3600 + minutes * 60 + seconds
end
hours = time / 3600
minutes = (time % 3600) / 60
seconds = (time % 3600) % 60
puts " %02d:%02d:%02d total time" % [hours, minutes, seconds]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment