From 4fbbdbc95a7959a5cf8ecb5df7126c76e52a06fe Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 14 Apr 2015 21:36:53 +0800 Subject: Bug 1154252: Bug 1146767: triggers method on undefined value warning --- extensions/BugModal/lib/Util.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'extensions/BugModal') diff --git a/extensions/BugModal/lib/Util.pm b/extensions/BugModal/lib/Util.pm index daca86518..74311197a 100644 --- a/extensions/BugModal/lib/Util.pm +++ b/extensions/BugModal/lib/Util.pm @@ -25,7 +25,13 @@ sub date_str_to_time { return timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900); } state $tz //= DateTime::TimeZone->new( name => 'local' ); - return datetime_from($date, $tz)->epoch; + my $dt = datetime_from($date, $tz); + if (!$dt) { + # this should never happen + warn("invalid datetime '$date'"); + return undef; + } + return $dt->epoch; } 1; -- cgit v1.2.3-24-g4f1b