Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d0d93017

Von Jan Büren vor mehr als 3 Jahren hinzugefügt

  • ID d0d93017e6552e1135f545fb6facfdb2439a9e72
  • Vorgänger 270368ab
  • Nachfolger 6ed51626

Zeiterfassung: Eingabe-Datum einzeln prüfen und nicht doppelt konvertieren

Unterschiede anzeigen:

SL/BackgroundJob/ConvertTimeRecordings.pm
109 109

  
110 110

  
111 111
  # convert date from string to object
112
  my $from_date;
113
  my $to_date;
112
  my ($from_date, $to_date);
114 113
  try {
115
    $from_date   = DateTime->from_kivitendo($data->{from_date}) if $data->{from_date};
116
    $to_date     = DateTime->from_kivitendo($data->{to_date})   if $data->{to_date};
117
    die unless $from_date && $to_date;
114
    if ($self->params->{from_date}) {
115
      $from_date = DateTime->from_kivitendo($self->params->{from_date});
116
      # no undef and no other type.
117
      die unless ref $from_date eq 'DateTime';
118
    }
119
    if ($self->params->{to_date}) {
120
      $to_date = DateTime->from_kivitendo($self->params->{to_date});
121
      # no undef and no other type.
122
      die unless ref $to_date eq 'DateTime';
123
    }
118 124
  } catch {
119 125
    die t8("Cannot convert date.") ."\n" .
120
        t8("Input from string: #1", $data->{from_date}) . "\n" .
121
        t8("Input to string: #1", $data->{to_date}) . "\n" .
126
        t8("Input from string: #1", $self->params->{from_date}) . "\n" .
127
        t8("Input to string: #1", $self->params->{to_date}) . "\n" .
122 128
        t8("Details: #1", $_);
123 129
  };
124
  $from_date = DateTime->from_kivitendo($self->params->{from_date});
125
  $to_date   = DateTime->from_kivitendo($self->params->{to_date});
126
  # DateTime->from_kivitendo returns undef if the string cannot be parsed. Therefore test the result.
127 130

  
128 131
  $to_date->add(days => 1); # to get all from the to_date, because of the time part (15.12.2020 23.59 > 15.12.2020)
129 132

  

Auch abrufbar als: Unified diff