aboutsummaryrefslogtreecommitdiff
path: root/votify
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@orbis-terrarum.net>2011-03-12 10:56:05 +0000
committerRobin H. Johnson <robbat2@orbis-terrarum.net>2011-03-12 10:56:05 +0000
commit11454907181978b99c00db92949e046948aaee05 (patch)
tree48950622f9a84d95905721f16544deaa06dcee19 /votify
parentSet up final ballot. (diff)
downloadelections-11454907181978b99c00db92949e046948aaee05.tar.gz
elections-11454907181978b99c00db92949e046948aaee05.tar.bz2
elections-11454907181978b99c00db92949e046948aaee05.zip
Alter *ify code to support an epoch value in a file instead of the mtime of the file.
Diffstat (limited to 'votify')
-rwxr-xr-xvotify17
1 files changed, 15 insertions, 2 deletions
diff --git a/votify b/votify
index c8d4e40..2e295bc 100755
--- a/votify
+++ b/votify
@@ -24,13 +24,26 @@ use strict;
(my $version = '$Revision: 1.5 $') =~ s/.*?(\d.*\d).*/$zero version $1\n/;
my (%opt);
+sub grabfile_int {
+ my $f = shift;
+ open FILE, "<", $f;
+ $i = <FILE>;
+ close FILE;
+ chomp $i;
+ return $i + 0;
+}
+
# 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-$_");
+ my ($startfile) = sprintf "%s/start-%s", $Votify::datadir, $_;
+ my ($stopfile) = sprintf "%s/stop-%s", $Votify::datadir, $_;
+ my ($starttime) = grabfile_int($startfile);
+ my ($stoptime) = grabfile_int($stopfile);
+ $starttime = (stat _)[9] if stat($startfile) and (!defined($starttime) or ($starttime <= 0));
+ $stoptime = (stat _)[9] if stat($stopfile) and (!defined($stoptime) or ($stoptime <= 0));
((not defined $starttime or $starttime < time) and
(not defined $stoptime or $stoptime > time))
}