diff options
| author | Zack Hobson | 2009-07-21 08:41:47 -0700 |
|---|---|---|
| committer | Zack Hobson | 2009-07-21 08:41:47 -0700 |
| commit | 695248d189b2843cb4d4fd5ce0b8de4bb28f82d1 (patch) | |
| tree | 478a03ede19ee839f7e2bacd8b0b4a6c76915ef9 /lib | |
| parent | 614c3b07bfd5ba18670e2af399247174770001f0 (diff) | |
| download | hcl-695248d189b2843cb4d4fd5ce0b8de4bb28f82d1.tar.bz2 | |
Display hours as HH:MM, closes #3.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/hcl.rb | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -83,11 +83,17 @@ class HCl total_hours = 0.0 DayEntry.all(date).each do |day| # TODO more information and formatting options - puts "\t#{day.hours}\t#{day.project} #{day.notes}"[0..78] + puts "\t#{as_hours day.hours}\t#{day.project} #{day.notes}"[0..78] total_hours = total_hours + day.hours.to_f end puts "\t" + '-' * 13 - puts "\t#{total_hours}\ttotal" + puts "\t#{as_hours total_hours}\ttotal" + end + + # Convert from decimal to a string of the form HH:MM. + def as_hours hours + minutes = hours.to_f * 60.0 + "#{(minutes / 60).to_i}:#{(minutes % 60).to_i}" end def not_implemented *args |
