From 01e627b6412bbb3d2fc82900014c118dc5b06a57 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 2 Jan 2014 14:42:16 +0000 Subject: [PATCH] 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 Signed-off-by: Katrin Fischer Passes all tests and QA script, especially t/DateUtils.t. Signed-off-by: Galen Charlton (cherry picked from commit b529ca00e0cac093fc32a1d123cdbcc84582c155) Signed-off-by: Fridolin Somers --- Koha/DateUtils.pm | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 4ae0d0ce69..ea57778425 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -130,31 +130,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"); + } + 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"); } - return; + else { + return $dateonly + ? $dt->strftime("%Y-%m-%d") + : $dt->strftime("%Y-%m-%d $time"); + } + } =head2 output_pref_due -- 2.39.5