-
-
Save nickyp/4572970 to your computer and use it in GitHub Desktop.
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 | |
require 'date' | |
re_line1 = /^\[b([\d,]+)h\](.*)/ | |
re_line2 = /^scheduled (.*)/ | |
total_hours = 0.0 | |
STDIN.each_slice(3) { |entry| # iterate per 3 lines | |
hours_and_description, schedule = entry[0], entry[1] | |
hours_and_description =~ re_line1 | |
hours, title = $1, $2 | |
total_hours += hours.gsub(",", ".").to_f | |
schedule =~ re_line2 | |
date = Date.parse($1) | |
puts "#{date.strftime('%d-%m-%y')}\t#{hours.ljust(4)}\t#{title}" | |
} | |
puts "\nTotaal: #{total_hours}" |
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
[b4h] WORK @ Sample project | |
scheduled 24 Oct 2012 from 08:00 to 12:00 | |
[b3,5h] Sample project | |
scheduled 5 Nov 2012 from 08:30 to 12:00 | |
[b3,75h] Sample project | |
scheduled 5 Nov 2012 from 08:30 to 12:00 |
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
24-10-12 4 WORK @ Sample project | |
05-11-12 3,5 Sample project | |
05-11-12 3,75 Sample project | |
Totaal: 11.25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your input :)
Unfortunately I'm not well versed in Ruby.
As stated in the blogpost I am looking for someone who can write this but also expand on it if I have additional requests (this is why I want it to be a paid project so I don't have to depend on someone's goodwill/free time)
I didn't expect people to start writing code already, I guess it's a small "programmer's challenge" :)