X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=AwayMsg.pm;h=d6f63a5b3e42bb96769845f7a57602b4d3d541d4;hb=a8266f995aee0cf7c39c27d9d73b267e56049374;hp=483345524ee2dedb1eae5678b601e78e97494b70;hpb=0652dacb9b7ebbdd9c5ec7502ee5a5533a22cdc8;p=nj-awaymsg.git diff --git a/AwayMsg.pm b/AwayMsg.pm index 4833455..d6f63a5 100644 --- a/AwayMsg.pm +++ b/AwayMsg.pm @@ -12,7 +12,8 @@ BEGIN { our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); - @EXPORT = qw(db_connect db_commit expires2timet + @EXPORT = qw(db_connect db_commit + expires2timet expirestime2show $dbh); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); @@ -49,7 +50,7 @@ sub nooutput ($) { sub expires2timet ($) { my ($str) = @_; - if ($str eq '') { + if ($str eq '' or $str =~ m/never/i) { return undef; } open F, "-|", qw(date -d),'$str',qw(+%s) or die $!; @@ -59,11 +60,20 @@ sub expires2timet ($) { return $dtime+0; } +sub expirestime2show ($) { + my ($tt) = @_; + if (!defined $tt) { + return 'never'; + } else { + return strftime("%Y-%m-%d %H:%M"); + } +} + sub db_commit () { nooutput("SELECT * FROM addresses LEFT JOIN config". " USING (emailaddr) WHERE forwardfile IS NULL"); nooutput("SELECT * FROM addresses LEFT JOIN texts". - " USING (textid) WHERE name IS NULL"); + " USING (textid) WHERE desc IS NULL"); $dbh->do("COMMIT"); }