Register timestamp of zero crossing in accounts file

This commit is contained in:
Juerd Waalboer 2019-08-28 18:48:31 +02:00
parent fa60e1081a
commit 4178009405

View file

@ -42,9 +42,15 @@ sub update {
if (lc $a[0] eq lc $username) {
$old = $a[1];
$new = $old + $delta;
printf {$out} "%-16s %+9.2f %s",
$username, $new, now() or die $!;
print {$out} "\n" or die $!;
my $since = $a[3] // "";
$since = "+\@" . now() if $new > 0 and (!$since or $old <= 0);
$since = "-\@" . now() if $new < 0 and (!$since or $old >= 0);
$since = "0\@" . now() if $new == 0 and (!$since or $old != 0);
printf {$out} "%-16s %+9.2f %s %s\n", (
$username, $new, now(), $since
) or die $!;
} else {
print {$out} $line or die $!;
}