Bug 13242: Remove warning if no parameter given
Without any parameter, dt_from_string should not raise a warning message. Test plan: Verify that the test file t/DateUtils.t displays a warning: Use of uninitialized value $date_string in pattern match (m//) at Koha/DateUtils.pm line 58 if the change in dt_from_string is not applied (manually edit the file). Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
6e75899b00
commit
f63aaf2242
2 changed files with 5 additions and 2 deletions
|
@ -56,7 +56,7 @@ sub dt_from_string {
|
|||
|
||||
# FIXME: see bug 13242 => no TZ for dates 'infinite'
|
||||
return DateTime::Format::DateParse->parse_datetime($date_string)
|
||||
if $date_string =~ /^9999-/;
|
||||
if $date_string and $date_string =~ /^9999-/;
|
||||
|
||||
if ( !$tz ) {
|
||||
$tz = C4::Context->tz;
|
||||
|
|
|
@ -3,7 +3,7 @@ use DateTime;
|
|||
use DateTime::TimeZone;
|
||||
|
||||
use C4::Context;
|
||||
use Test::More tests => 41;
|
||||
use Test::More tests => 42;
|
||||
use Test::MockModule;
|
||||
use Time::HiRes qw/ gettimeofday /;
|
||||
|
||||
|
@ -159,3 +159,6 @@ $date_string = output_pref({ dt => $dt, dateformat => 'metric', timeformat => '2
|
|||
cmp_ok $date_string, 'eq', '11/12/2013 18:35', 'as_due_date with hours and timeformat 24hr (non-midnight time)';
|
||||
$date_string = output_pref({ dt => $dt, dateformat => 'us', timeformat => '12hr', as_due_date => 1 });
|
||||
cmp_ok $date_string, 'eq', '12/11/2013 06:35 PM', 'as_due_date with hours and timeformat 12hr (non-midnight time)';
|
||||
|
||||
my $now = DateTime->now;
|
||||
is( dt_from_string, $now, "Without parameter, dt_from_string should return today" );
|
||||
|
|
Loading…
Reference in a new issue