diff options
author | 2010-06-16 19:30:42 +0000 | |
---|---|---|
committer | 2010-06-16 19:30:42 +0000 | |
commit | 716f7b11c380cb07434fd86bf5728574e9d54073 (patch) | |
tree | 15c156e1621e0be5e69a40ac3bbdb8c4f086b71f /countify | |
parent | Copy in all of the elections stuff. (diff) | |
download | elections-716f7b11c380cb07434fd86bf5728574e9d54073.tar.gz elections-716f7b11c380cb07434fd86bf5728574e9d54073.tar.bz2 elections-716f7b11c380cb07434fd86bf5728574e9d54073.zip |
Show open elections in countify.
Diffstat (limited to 'countify')
-rwxr-xr-x | countify | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -23,6 +23,26 @@ use strict; (my $zero = $0) =~ s,.*/,,; (my $version = '$Revision: 1.3 $') =~ s/.*?(\d.*\d).*/$zero version $1\n/; my %opt; + +# Collect the open elections +my (@open_elections, $usage_elections); +opendir(D, "$Votify::datadir/") or die; +@open_elections = sort grep { + s/^start-// and do { + my ($starttime) = (stat _)[9] if stat("$Votify::datadir/start-$_"); + my ($stoptime) = (stat _)[9] if stat("$Votify::datadir/stop-$_"); + ((not defined $starttime or $starttime < time) and + (not defined $stoptime or $stoptime > time)) + } +} readdir D; +closedir D; +if (@open_elections) { + $usage_elections = join("\n ", @open_elections); +} else { + $usage_elections = "(no elections currently open)"; +} + +# rest of usage my $usage = <<EOT; usage: $zero <command> <election> @@ -37,7 +57,7 @@ where <command> is one of: and <election> is one of the elections currently in-progress. The following elections are currently open: - trustees2005 + $usage_elections EOT |