| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::Jiffy::View::Timesheet; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 8 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 30 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 87 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 7 | use App::Jiffy::TimeEntry; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 38 |  | 
| 7 | 1 |  |  | 1 |  | 438 | use App::Jiffy::Util::Duration qw/round/; | 
|  | 1 |  |  |  |  | 10 |  | 
|  | 1 |  |  |  |  | 61 |  | 
| 8 | 1 |  |  | 1 |  | 932 | use DateTime; | 
|  | 1 |  |  |  |  | 475883 |  | 
|  | 1 |  |  |  |  | 385 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | sub render { | 
| 11 | 0 |  |  | 0 | 0 |  | my $entries = shift; | 
| 12 | 0 |  |  |  |  |  | my $options = shift; | 
| 13 | 0 |  |  |  |  |  | my $from    = $options->{from}; | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | # Header | 
| 16 | 0 | 0 |  |  |  |  | if ($from) { | 
| 17 | 0 |  |  |  |  |  | print "The past " . $from . " days' timesheet:\n\n"; | 
| 18 |  |  |  |  |  |  | } else { | 
| 19 | 0 |  |  |  |  |  | print "Today's timesheet:\n\n"; | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 0 |  |  |  |  |  | my $current_day = $entries->[0]->start_time->clone->truncate( to => 'day' ); | 
| 23 | 0 | 0 |  |  |  |  | if ($from) { | 
| 24 | 0 |  |  |  |  |  | print "Date: " . $current_day->mdy('/') . "\n"; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 0 |  |  |  |  |  | foreach my $entry (@$entries) { | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 0 |  |  |  |  |  | my $start_time = $entry->start_time->clone; | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 0 | 0 |  |  |  |  | if ( | 
| 32 |  |  |  |  |  |  | DateTime->compare( $current_day, $start_time->truncate( to => 'day' ) ) | 
| 33 |  |  |  |  |  |  | == -1 ) | 
| 34 |  |  |  |  |  |  | { | 
| 35 | 0 |  |  |  |  |  | $current_day = $start_time->truncate( to => 'day' ); | 
| 36 | 0 |  |  |  |  |  | print "\nDate: " . $current_day->mdy('/') . "\n"; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | # Get the deltas | 
| 40 | 0 |  |  |  |  |  | my $duration = $entry->duration; | 
| 41 | 0 |  |  |  |  |  | my %deltas   = $duration->deltas; | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 0 |  |  |  |  |  | foreach my $unit ( sort keys %deltas ) { | 
| 44 | 0 | 0 |  |  |  |  | next unless $deltas{$unit}; | 
| 45 | 0 |  |  |  |  |  | print $deltas{$unit} . " " . $unit . " "; | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | # Print entry | 
| 49 | 0 | 0 |  |  |  |  | if ( $options->{verbose} ) { | 
| 50 | 0 |  |  |  |  |  | my ($clock_time) = $entry->start_time->hms =~ /(.*):.*$/; | 
| 51 | 0 |  |  |  |  |  | print "\t " . | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | # Time | 
| 54 |  |  |  |  |  |  | $clock_time . | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | # Title | 
| 57 |  |  |  |  |  |  | "\t" . $entry->title . "\n"; | 
| 58 |  |  |  |  |  |  | } else { | 
| 59 | 0 |  |  |  |  |  | print "\t " . $entry->title . "\n"; | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | 1; |