From cb0d3042beaacdd17a6d1422102970e0b6a8b55f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 1 Feb 2007 11:18:19 +0000 Subject: [PATCH] =?utf8?q?Keine=20globalen=20Variablen=20benutzen.=20Au?= =?utf8?q?=C3=9Ferdem=20die=20etwas=20h=C3=A4ssliche=20if/else-Kaskadierun?= =?utf8?q?g=20entfernt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Form.pm | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 85634caf4..b12cb9e11 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -576,31 +576,19 @@ sub write_trigger { # set dateform for jsscript # default - $ifFormat = "%d.%m.%Y"; - if ($myconfig->{dateformat} eq "dd.mm.yy") { - $ifFormat = "%d.%m.%Y"; - } else { - if ($myconfig->{dateformat} eq "dd-mm-yy") { - $ifFormat = "%d-%m-%Y"; - } else { - if ($myconfig->{dateformat} eq "dd/mm/yy") { - $ifFormat = "%d/%m/%Y"; - } else { - if ($myconfig->{dateformat} eq "mm/dd/yy") { - $ifFormat = "%m/%d/%Y"; - } else { - if ($myconfig->{dateformat} eq "mm-dd-yy") { - $ifFormat = "%m-%d-%Y"; - } else { - if ($myconfig->{dateformat} eq "yyyy-mm-dd") { - $ifFormat = "%Y-%m-%d"; - } - } - } - } - } - } + my %dateformats = ( + "dd.mm.yy" => "%d.%m.%Y", + "dd-mm-yy" => "%d-%m-%Y", + "dd/mm/yy" => "%d/%m/%Y", + "mm/dd/yy" => "%m/%d/%Y", + "mm-dd-yy" => "%m-%d-%Y", + "yyyy-mm-dd" => "%Y-%m-%d", + ); + + my $ifFormat = defined($dateformats{$myconfig{"dateformat"}}) ? + $dateformats{$myconfig{"dateformat"}} : "%d.%m.%Y"; + my @triggers; while ($#_ >= 2) { push @triggers, qq| Calendar.setup( -- 2.20.1