From 80ee10d13a4fce560d61a833a6f70ea6aca6a765 Mon Sep 17 00:00:00 2001 From: jagtalon Date: Mon, 25 Aug 2014 18:52:58 +0000 Subject: [PATCH] UnixTime: Disable the no argument feature. Disabling the no argument feature since: - It triggers with just "time" - The time shown doesn't follow the person's timezone (which is preferable over UTC) --- lib/DDG/Goodie/UnixTime.pm | 2 +- t/UnixTime.t | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/DDG/Goodie/UnixTime.pm b/lib/DDG/Goodie/UnixTime.pm index 93cee63d6..177f8f11c 100644 --- a/lib/DDG/Goodie/UnixTime.pm +++ b/lib/DDG/Goodie/UnixTime.pm @@ -20,9 +20,9 @@ category 'calculations'; topics 'sysadmin'; handle remainder => sub { + return unless defined $_; my $time_input = shift; - $time_input = time if ($time_input eq ''); # Default to 'now' when empty. my $time_utc; eval { $time_input = int(length($time_input) >= 13 ? ($time_input / 1000) : ($time_input + 0)); diff --git a/t/UnixTime.t b/t/UnixTime.t index 007703ecd..1bdb58aed 100644 --- a/t/UnixTime.t +++ b/t/UnixTime.t @@ -15,9 +15,9 @@ ddg_goodie_test([qw( 'unix time 0000000000000' => test_zci('Unix Time: Thu Jan 01 00:00:00 1970 +0000'), 'epoch 0' => test_zci('Unix Time: Thu Jan 01 00:00:00 1970 +0000'), 'epoch 2147483647' => test_zci('Unix Time: Tue Jan 19 03:14:07 2038 +0000'), - 'epoch' => test_zci(qr/Unix Time: [^\+]+\+0000/), # Now in UTC. - 'timestamp' => test_zci(qr/Unix Time: [^\+]+\+0000/), # Now in UTC. - 'datetime' => test_zci(qr/Unix Time: [^\+]+\+0000/), # Now in UTC. + #'epoch' => test_zci(qr/Unix Time: [^\+]+\+0000/), # Now in UTC. + #'timestamp' => test_zci(qr/Unix Time: [^\+]+\+0000/), # Now in UTC. + #'datetime' => test_zci(qr/Unix Time: [^\+]+\+0000/), # Now in UTC. ); done_testing;