From: Moritz Bunkus Date: Mon, 18 Dec 2006 10:27:27 +0000 (+0000) Subject: Funktion in Locale implementiert, um ein Datum in einem anderen Format auszugeben. X-Git-Tag: release-2.4.1~1^2~132 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3edbebcca44b30651a2474d6b5735ebbd7113b28;p=kivitendo-erp.git Funktion in Locale implementiert, um ein Datum in einem anderen Format auszugeben. --- diff --git a/SL/Form.pm b/SL/Form.pm index ec41cc074..80ff5accf 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2546,4 +2546,33 @@ sub parse_date { return ($yy, $mm, $dd); } +sub reformat_date { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $date, $output_format, $longformat) = @_; + + $main::lxdebug->leave_sub() and return "" unless ($date); + + my ($yy, $mm, $dd) = $self->parse_date($myconfig, $date); + + $output_format =~ /d+/; + substr($output_format, $-[0], $+[0] - $-[0]) = + sprintf("%0" . (length($&)) . "d", $dd); + + $output_format =~ /m+/; + substr($output_format, $-[0], $+[0] - $-[0]) = + sprintf("%0" . (length($&)) . "d", $mm); + + $output_format =~ /y+/; + if (length($&) == 2) { + $yy -= $yy >= 2000 ? 2000 : 1900; + } + substr($output_format, $-[0], $+[0] - $-[0]) = + sprintf("%0" . (length($&)) . "d", $yy); + + $main::lxdebug->leave_sub(); + + return $output_format; +} + 1;