From 8484285f05cdb419d89c4385d8889117bbd2df62 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 18 Feb 2010 16:04:01 +0100 Subject: [PATCH] =?utf8?q?Datum=20formatieren:=20Optional=20L=C3=A4nge=20d?= =?utf8?q?es=20Jahresfeldes=20angeben?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Locale.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/SL/Locale.pm b/SL/Locale.pm index 066808123..47268ec64 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -401,14 +401,21 @@ sub reformat_date { sub format_date { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $yy, $mm, $dd) = @_; + my $self = shift; + my $myconfig = shift; + my $yy = shift; + my $mm = shift; + my $dd = shift; + my $yy_len = shift || 4; $main::lxdebug->leave_sub() and return "" unless $yy && $mm && $dd; - my $format = $myconfig->{dateformat}; + $yy = $yy % 100 if 2 == $yy_len; + + my $format = ref $myconfig eq '' ? "$myconfig" : $myconfig->{dateformat}; $format =~ s{ d+ }{ sprintf("%0" . (length($&)) . "d", $dd) }gex; $format =~ s{ m+ }{ sprintf("%0" . (length($&)) . "d", $mm) }gex; - $format =~ s{ y+ }{ sprintf("%4d", $yy) }gex; + $format =~ s{ y+ }{ sprintf("%0${yy_len}d", $yy) }gex; $main::lxdebug->leave_sub(); -- 2.20.1