From: Greg Sabino Mullane Date: Fri, 17 Apr 2009 21:34:25 +0000 (-0400) Subject: Allow week and year in some time inputs. X-Git-Tag: 2.9.0~111 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=b11d503bc3c9b1128203bc6e341a5dd8e724bb8f;p=check_postgres.git Allow week and year in some time inputs. --- diff --git a/check_postgres.pl b/check_postgres.pl index 1ebe1b5db..7525738a0 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -746,6 +746,7 @@ sub msg { ## no critic my $x=1; { my $val = $_[$x-1]; + $val = '?' if ! defined $val; last unless $msg =~ s/\$$x/$val/g; $x++; redo; @@ -1741,11 +1742,18 @@ sub size_in_seconds { return '' if ! length $string; if ($string !~ $timere) { - my $l = substr($type,0,1); - ndie msg('die-badtime', $type, $l); + ndie msg('die-badtime', $type, substr($type,0,1)); } my ($val,$unit) = ($1,lc substr($2||'s',0,1)); - my $tempval = sprintf '%.9f', $val * ($unit eq 's' ? 1 : $unit eq 'm' ? 60 : $unit eq 'h' ? 3600 : 86600); + my $tempval = sprintf '%.9f', $val * ( + $unit eq 's' ? 1 : + $unit eq 'm' ? 60 : + $unit eq 'h' ? 3600 : + $unit eq 'd' ? 86400 : + $unit eq 'w' ? 604800 : + $unit eq 'y' ? 31536000 : + ndie msg('die-badtime', $type, substr($type,0,1)) + ); $tempval =~ s/0+$//; $tempval = int $tempval if $tempval =~ /\.$/; return $tempval;