version 1.1, 2020/08/04 02:14:42 |
version 1.3, 2020/08/04 02:23:48 |
|
|
#!/usr/bin/perl |
#!/usr/bin/perl |
# $AFresh1$ |
# $AFresh1: report_time,v 1.2 2020/08/04 01:22:44 afresh1 Exp $ |
use v5.16; |
use v5.16; |
use warnings; |
use warnings; |
|
|
|
|
close $fh; |
close $fh; |
} |
} |
|
|
|
my %total; |
foreach my $key (sort keys %entries) { |
foreach my $key (sort keys %entries) { |
my %total; |
|
my $start; |
my $start; |
foreach my $entry (@{ $entries{$key} }) { |
foreach my $entry (@{ $entries{$key} }) { |
|
|
|
|
$entry->{datetime} = Time::Piece->new->strptime( |
$entry->{datetime} = Time::Piece->new->strptime( |
$entry->{dt}, "%a %b %e %H:%M:%S %Z %Y"); |
$entry->{dt}, "%a %b %e %H:%M:%S %Z %Y"); |
|
|
$total{ $entry->{datetime}->date } |
$total{ $entry->{datetime}->date }{$key} |
+= $entry->{datetime} - $start->{datetime} |
+= $entry->{datetime} - $start->{datetime} |
if $start; |
if $start; |
|
|
|
|
# If we have a timer running, pretend it stops now. |
# If we have a timer running, pretend it stops now. |
if ($start) { |
if ($start) { |
my $now = localtime; |
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} } ) { |
|
my $hours = $total{$date}{$key}->hours; |
|
|
# round to the quarter hour |
# round to the quarter hour |
my $hours = sprintf "%.2f", |
$hours = sprintf "%.2f", |
25 * sprintf "%.2f", $total{$date}->hours / 25; |
25 * sprintf "%.2f", $hours / 25; |
say "$date $hours $key" if $hours != 0; |
|
|
say "$date $hours $key";# if $hours != 0; |
} |
} |
} |
} |
|
|