]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Locale.pm
Locale: Bei parase_date_string undef sofort undef zurückgeben.
[mfinanz.git] / SL / Locale.pm
index 23a399e10fe1b37ea23bfbf8e678640faee12b50..d1d9f04b4027a56b2dbb7b50ff062ee856992fbe 100644 (file)
@@ -364,8 +364,8 @@ sub parse_date {
     ($yy, $mm, $dd) = ($date =~ /(..)(..)(..)/);
   }
 
-  $dd *= 1;
-  $mm *= 1;
+  $_ ||= 0 for ($dd, $mm, $yy);
+  $_ *= 1  for ($dd, $mm, $yy);
   $yy = ($yy < 70) ? $yy + 2000 : $yy;
   $yy = ($yy >= 70 && $yy <= 99) ? $yy + 1900 : $yy;
 
@@ -376,6 +376,8 @@ sub parse_date {
 sub parse_date_to_object {
   my ($self, $string, %params) = @_;
 
+  return undef if !defined $string;
+
   $params{dateformat}        ||= $::myconfig{dateformat}   || 'yy-mm-dd';
   $params{numberformat}      ||= $::myconfig{numberformat} || '1,000.00';
   my $num_separator            = $params{numberformat} =~ m{,\d+$} ? ',' : '.';
@@ -383,9 +385,12 @@ sub parse_date_to_object {
   my ($date_str, $time_str)    = split m{\s+}, $string, 2;
   my ($yy, $mm, $dd)           = $self->parse_date(\%params, $date_str);
 
-  my $millisecond              = 0;
-  my ($hour, $minute, $second) = split m/:/, $time_str;
-  ($second, $millisecond)      = split quotemeta($num_separator), $second, 2;
+  my ($hour, $minute, $second) = split m/:/, ($time_str || '');
+  $second ||= '0';
+
+  ($second, my $millisecond)   = split quotemeta($num_separator), $second, 2;
+  $_ ||= 0 for ($hour, $minute, $millisecond);
+
   $millisecond                 = substr $millisecond, 0, 3;
   $millisecond                .= '0' x (3 - length $millisecond);