| 1 | package App::Jiffy::View::Timesheet; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use App::Jiffy::TimeEntry; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use App::Jiffy::Util::Duration qw/round/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use DateTime; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 0 | ▶ | sub render { | ||||||||
|
Subroutine
render: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||
| 11 | 0 | my $entries = shift; | |||||||||
| 12 | 0 | my $options = shift; | |||||||||
| 13 | 0 | my $from = $options->{from}; | |||||||||
| 14 | |||||||||||
| 15 | # Header | ||||||||||
| 16 | 0 | ▶ | if ($from) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | if ($from) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | if ( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | next unless $deltas{$unit}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | print $deltas{$unit} . " " . $unit . " "; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | # Print entry | ||||||||||
| 49 | 0 | ▶ | if ( $options->{verbose} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 1; | |||||||||