Bug 11468: Remove given/when from Koha::Dateutils

given and when give warnings due to their experimental
status as of perl 5.18. Replace the construct with
an if/elsif to avoid the keywords

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script, especially t/DateUtils.t.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit b529ca00e0)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 01e627b641)
This commit is contained in:
Colin Campbell 2014-01-02 14:42:16 +00:00 committed by Kyle M Hall
parent a5d366ab59
commit fa69b2d074
1 changed files with 21 additions and 24 deletions

View File

@ -124,31 +124,28 @@ sub output_pref {
my $time_format = $force_time || C4::Context->preference('TimeFormat');
my $time = ( $time_format eq '12hr' ) ? '%I:%M %p' : '%H:%M';
given ($pref) {
when (/^iso/) {
return $dateonly
? $dt->strftime("%Y-%m-%d")
: $dt->strftime("%Y-%m-%d $time");
}
when (/^metric/) {
return $dateonly
? $dt->strftime("%d/%m/%Y")
: $dt->strftime("%d/%m/%Y $time");
}
when (/^us/) {
return $dateonly
? $dt->strftime("%m/%d/%Y")
: $dt->strftime("%m/%d/%Y $time");
}
default {
return $dateonly
? $dt->strftime("%Y-%m-%d")
: $dt->strftime("%Y-%m-%d $time");
}
if ( $pref =~ m/^iso/ ) {
return $dateonly
? $dt->strftime("%Y-%m-%d")
: $dt->strftime("%Y-%m-%d $time");
}
return;
elsif ( $pref =~ m/^metric/ ) {
return $dateonly
? $dt->strftime("%d/%m/%Y")
: $dt->strftime("%d/%m/%Y $time");
}
elsif ( $pref =~ m/^us/ ) {
return $dateonly
? $dt->strftime("%m/%d/%Y")
: $dt->strftime("%m/%d/%Y $time");
}
else {
return $dateonly
? $dt->strftime("%Y-%m-%d")
: $dt->strftime("%Y-%m-%d $time");
}
}
=head2 output_pref_due