From: Don Armstrong Date: Wed, 13 Mar 2013 00:13:55 +0000 (-0700) Subject: update make invoice to handle org mode timestamps X-Git-Url: https://git.donarmstrong.com/?p=bin.git;a=commitdiff_plain;h=381daee1720ade751b5342b972912f94a6cc1f76 update make invoice to handle org mode timestamps --- diff --git a/make_invoice b/make_invoice index 6c7e4a1..5f87df4 100755 --- a/make_invoice +++ b/make_invoice @@ -186,11 +186,18 @@ while (<$log_fh>) { $date = undef; $time = undef; } - s/\s*\[[\.\d]+\]\s*\[[\.\d]+\]\s*$//; - my $string = $_; - my ($d1,$d2) = map {s/^\s*\*\s*//; - UnixDate(ParseDate($_),'%s') - } split /\s*-\s*/; + s/\s*\[[\.\d]+\]\s*\[[\.\d]+\]\s*$//; + my ($d1,$d2); + if (/\s*\*\s*CLOCK:\s+\[([^\]]+)\]--\[([^\]]+)\]/) { + $d1 = UnixDate(ParseDate($1),'%s'); + $d2 = UnixDate(ParseDate($2),'%s'); + } else { + ($d1,$d2) = map {s/^\s*\*\s*//; + UnixDate(ParseDate($_),'%s') + } split /\s*-\s*/; + } + my $string = '* '.strftime('%A, %B %e, %H:%M:%S',localtime($d1)).' - '. + strftime('%A, %B %e, %H:%M:%S',localtime($d2)); if (not defined $first_date) { $first_date = $d1; } @@ -207,7 +214,7 @@ while (<$log_fh>) { } $time = $hours; $totaldelta += $delta; - $calc_log .= qq($string [).sprintf('%.2f',$hours).qq(] [).sprintf('%.2f',$totaldelta/(60*60)).qq(]\n); + $calc_log .= $string.q( [).sprintf('%.2f',$hours).qq(] [).sprintf('%.2f',$totaldelta/(60*60)).qq(]\n); } elsif (/^\s+-\s*(.+)/) { my $event = $1;