diff options
author | Bradley M. Kuhn <bkuhn@ebb.org> | 2012-11-25 14:33:53 -0500 |
---|---|---|
committer | Bradley M. Kuhn <bkuhn@ebb.org> | 2012-11-26 13:54:47 -0500 |
commit | 10d3f5593302b07897f88d7b9c771558af4a2738 (patch) | |
tree | ec0dc21b6ad1e1e9ff083912dee40ecbc5cca1fe /contrib | |
parent | df6428f549a3a82d52bb18b1e71b468e35b2c444 (diff) | |
download | fork-ledger-10d3f5593302b07897f88d7b9c771558af4a2738.tar.gz fork-ledger-10d3f5593302b07897f88d7b9c771558af4a2738.tar.bz2 fork-ledger-10d3f5593302b07897f88d7b9c771558af4a2738.zip |
Print date in a more friendly format.
Includes issue of "ends on" date being correct for mere mortals as opposed
to being right for Ledger only.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/non-profit-audit-reports/fund-report.plx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/contrib/non-profit-audit-reports/fund-report.plx b/contrib/non-profit-audit-reports/fund-report.plx index 5b74a606..0c03d009 100755 --- a/contrib/non-profit-audit-reports/fund-report.plx +++ b/contrib/non-profit-audit-reports/fund-report.plx @@ -24,6 +24,7 @@ use strict; use warnings; use Math::BigFloat; +use Date::Manip; my $LEDGER_CMD = "/usr/local/bin/ledger"; @@ -42,6 +43,13 @@ if (@ARGV < 2) { } my($startDate, $endDate, @mainLedgerOptions) = @ARGV; +my $err; +my $formattedEndDate = UnixDate(DateCalc(ParseDate($endDate), ParseDateDelta("- 1 day"), \$err), + "%B %e, %Y"); +die "Date calculation error on $endDate" if ($err); +my $formattedStartDate = UnixDate(ParseDate($startDate), "%B %e, %Y"); +die "Date calculation error on $startDate" if ($err); + # First, get fund list from ending balance my(@ledgerOptions) = (@mainLedgerOptions, '-V', '-X', '$', '-F', "%-.70A %22.108t\n", '-s', @@ -117,14 +125,14 @@ my($totStart, $totEnd) = ($ZERO, $ZERO); foreach my $fund (sort keys %funds) { my $sanityTotal = $funds{$fund}{starting}; - print "Fund: $fund\n", sprintf("%-35s\$%26.2f\n\n", "Balance as of $startDate:", + print "Fund: $fund\n", sprintf("%-35s\$%26.2f\n\n", "Balance as of $formattedStartDate:", $funds{$fund}{starting}); foreach my $type ('Income', 'Expenses', @possibleTypes) { my $formattedType = $type; $formattedType =~ s/^Accrued://; next if $type ne 'Income' and $type ne 'Expenses' and $funds{$fund}{$type} == $ZERO; print sprintf("%19s during period: \$%26.2f\n", $formattedType, $funds{$fund}{$type}); } - print sprintf("\n%-35s\$%26.2f\n", "Balance as of $endDate:", + print sprintf("\n%-35s\$%26.2f\n", "Balance as of $formattedEndDate:", $funds{$fund}{ending}), "\n\n"; # Santity check: if ($funds{$fund}{ending} != @@ -136,8 +144,8 @@ foreach my $fund (sort keys %funds) { $totStart += $funds{$fund}{starting}; $totEnd += $funds{$fund}{ending}; } -print "\n\n\nTotal Restricted Funds as of $startDate: ", sprintf("\$%15.2f\n", $totStart); -print "\nTotal Restricted Funds as of $endDate: ", sprintf("\$%15.2f\n", $totEnd); +print "\n\n\nTotal Restricted Funds as of $formattedStartDate: ", sprintf("\$%15.2f\n", $totStart); +print "\nTotal Restricted Funds as of $formattedStartDate: ", sprintf("\$%15.2f\n", $totEnd); ############################################################################### # # Local variables: |