8 return sprintf("%d:%02d", hours, min)
13 f = File.open(ARGV[0], "r")
15 next if (line =~ /^[\t ]*$/)
16 raise "can't parse line" unless (line =~ /^([0-9]*):([0-9][0-9])/)
19 # puts "hour = #{hour}"
21 raise "invalid hour count of #{hour}" if (hour >= 24)
22 raise "invalid minutes count of #{min}" if (min >= 60)
23 total_min = (hour * 60) + min
32 raise "punch #{index} is not greater than the previous one"
37 total_clocked_time = 0
42 mandatory_breaks = [ 30, 15, 15 ]
43 mandatory_breaks = mandatory_breaks.sort!
44 mandatory_breaks = mandatory_breaks.reverse!
52 puts "punch #{index-1} to #{index}:\t\t#{pretty_time(inc)}"
53 total_clocked_time = total_clocked_time + inc
57 total_break_time = total_break_time + inc
59 str = "[unknown break]"
60 mandatory_breaks.each do |b|
63 total_clocked_time = total_clocked_time + b
64 mandatory_breaks.shift
68 puts "#{str} #{index-1} to #{index}:\t#{pretty_time(inc)}"
75 puts "total_clocked_time: #{pretty_time(total_clocked_time)}"
76 if (total_clocked_time < (7 * 60)) then
77 puts "ERROR: total clocked time is less than 7 hours!"
79 unless (mandatory_breaks.size() == 0) then
80 puts "ERROR: not all mandatory breaks were taken! Still have to take: #{mandatory_breaks.join(" ")}"