]> git.donarmstrong.com Git - bin.git/blob - invoice_calc
add common subscriber
[bin.git] / invoice_calc
1 #!/usr/bin/perl
2
3 use Date::Manip;
4
5 $totaldelta=undef;
6
7 while (<>) {
8      chomp;
9      if (/^\* /) {
10           my $string = $_; 
11           my ($d1,$d2) = map {s/^\*\s*//;
12                               ParseDate($_)
13                          } split /\s*-\s*/; 
14           my $delta = DateCalc($d1,$d2);
15           $totaldelta = defined($totaldelta)?DateCalc($delta,$totaldelta):$delta;
16           print qq($string [).Delta_Format($delta,2,q(%ht)).qq(] [).Delta_Format($totaldelta,2,q(%ht)).qq(]\n);
17      }
18      else {
19           print $_,qq(\n);
20      }
21 }
22
23 print "\nTotal: ".Delta_Format($totaldelta,2,q(%ht)).qq(\n);