From abde405dfaab376a13e9a1e3e24cd715fa7de024 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 28 Aug 2012 12:25:54 +0200 Subject: [PATCH] =?utf8?q?Kosmetik:=20Einr=C3=BCckung=20verringern=20durch?= =?utf8?q?=20Shortcut?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Locale.pm | 111 ++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/SL/Locale.pm b/SL/Locale.pm index 7c524e984..8a2caa2c0 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -277,73 +277,74 @@ sub date { my ($self, $myconfig, $date, $longformat) = @_; + if (!$date) { + $main::lxdebug->leave_sub(); + return ''; + } + my $longdate = ""; my $longmonth = ($longformat) ? 'LONG_MONTH' : 'SHORT_MONTH'; my ($spc, $yy, $mm, $dd); - if ($date) { - # get separator - $spc = $myconfig->{dateformat}; - $spc =~ s/\w//g; - $spc = substr($spc, 1, 1); + $spc = $myconfig->{dateformat}; + $spc =~ s/\w//g; + $spc = substr($spc, 1, 1); - if ($date =~ /\D/) { - if ($myconfig->{dateformat} =~ /^yy/) { - ($yy, $mm, $dd) = split /\D/, $date; - } - if ($myconfig->{dateformat} =~ /^mm/) { - ($mm, $dd, $yy) = split /\D/, $date; - } - if ($myconfig->{dateformat} =~ /^dd/) { - ($dd, $mm, $yy) = split /\D/, $date; - } - } else { - $date = substr($date, 2); - ($yy, $mm, $dd) = ($date =~ /(..)(..)(..)/); + if ($date =~ /\D/) { + if ($myconfig->{dateformat} =~ /^yy/) { + ($yy, $mm, $dd) = split /\D/, $date; + } + if ($myconfig->{dateformat} =~ /^mm/) { + ($mm, $dd, $yy) = split /\D/, $date; } + if ($myconfig->{dateformat} =~ /^dd/) { + ($dd, $mm, $yy) = split /\D/, $date; + } + } else { + $date = substr($date, 2); + ($yy, $mm, $dd) = ($date =~ /(..)(..)(..)/); + } - $dd *= 1; - $mm--; - $yy = ($yy < 70) ? $yy + 2000 : $yy; - $yy = ($yy >= 70 && $yy <= 99) ? $yy + 1900 : $yy; + $dd *= 1; + $mm--; + $yy = ($yy < 70) ? $yy + 2000 : $yy; + $yy = ($yy >= 70 && $yy <= 99) ? $yy + 1900 : $yy; - if ($myconfig->{dateformat} =~ /^dd/) { - if (defined $longformat && $longformat == 0) { - $mm++; - $dd = "0$dd" if ($dd < 10); - $mm = "0$mm" if ($mm < 10); - $longdate = "$dd$spc$mm$spc$yy"; - } else { - $longdate = "$dd"; - $longdate .= ($spc eq '.') ? ". " : " "; - $longdate .= &text($self, $self->{$longmonth}[$mm]) . " $yy"; - } - } elsif ($myconfig->{dateformat} eq "yyyy-mm-dd") { - - # Use German syntax with the ISO date style "yyyy-mm-dd" because - # Lx-Office is mainly used in Germany or German speaking countries. - if (defined $longformat && $longformat == 0) { - $mm++; - $dd = "0$dd" if ($dd < 10); - $mm = "0$mm" if ($mm < 10); - $longdate = "$yy-$mm-$dd"; - } else { - $longdate = "$dd. "; - $longdate .= &text($self, $self->{$longmonth}[$mm]) . " $yy"; - } + if ($myconfig->{dateformat} =~ /^dd/) { + if (defined $longformat && $longformat == 0) { + $mm++; + $dd = "0$dd" if ($dd < 10); + $mm = "0$mm" if ($mm < 10); + $longdate = "$dd$spc$mm$spc$yy"; } else { - if (defined $longformat && $longformat == 0) { - $mm++; - $dd = "0$dd" if ($dd < 10); - $mm = "0$mm" if ($mm < 10); - $longdate = "$mm$spc$dd$spc$yy"; - } else { - $longdate = &text($self, $self->{$longmonth}[$mm]) . " $dd, $yy"; - } + $longdate = "$dd"; + $longdate .= ($spc eq '.') ? ". " : " "; + $longdate .= &text($self, $self->{$longmonth}[$mm]) . " $yy"; + } + } elsif ($myconfig->{dateformat} eq "yyyy-mm-dd") { + + # Use German syntax with the ISO date style "yyyy-mm-dd" because + # Lx-Office is mainly used in Germany or German speaking countries. + if (defined $longformat && $longformat == 0) { + $mm++; + $dd = "0$dd" if ($dd < 10); + $mm = "0$mm" if ($mm < 10); + $longdate = "$yy-$mm-$dd"; + } else { + $longdate = "$dd. "; + $longdate .= &text($self, $self->{$longmonth}[$mm]) . " $yy"; + } + } else { + if (defined $longformat && $longformat == 0) { + $mm++; + $dd = "0$dd" if ($dd < 10); + $mm = "0$mm" if ($mm < 10); + $longdate = "$mm$spc$dd$spc$yy"; + } else { + $longdate = &text($self, $self->{$longmonth}[$mm]) . " $dd, $yy"; } - } $main::lxdebug->leave_sub(); -- 2.20.1