=================================================================== RCS file: /cvs/RT/Invoicing/report_time,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RT/Invoicing/report_time 2020/08/04 02:14:42 1.1 +++ RT/Invoicing/report_time 2020/08/04 02:22:44 1.2 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $AFresh1$ +# $AFresh1: report_time,v 1.1 2020/08/04 01:14:42 afresh1 Exp $ use v5.16; use warnings; @@ -51,8 +51,8 @@ close $fh; } +my %total; foreach my $key (sort keys %entries) { - my %total; my $start; foreach my $entry (@{ $entries{$key} }) { @@ -60,7 +60,7 @@ $entry->{datetime} = Time::Piece->new->strptime( $entry->{dt}, "%a %b %e %H:%M:%S %Z %Y"); - $total{ $entry->{datetime}->date } + $total{ $entry->{datetime}->date }{$key} += $entry->{datetime} - $start->{datetime} if $start; @@ -70,14 +70,16 @@ # If we have a timer running, pretend it stops now. if ($start) { my $now = localtime; - $total{ $now->date } += $now - $start->{datetime} + $total{ $now->date }{$key} += $now - $start->{datetime} } +} - foreach my $date ( sort keys %total ) { +foreach my $date ( sort keys %total ) { + foreach my $key ( sort keys %{ $total{$date} } ) { # round to the quarter hour my $hours = sprintf "%.2f", - 25 * sprintf "%.2f", $total{$date}->hours / 25; - say "$date $hours $key" if $hours != 0; + 25 * sprintf "%.2f", $total{$date}{$key}->hours / 25; + say "$date $hours $key";# if $hours != 0; } }