]> git.mjollnir.org Git - tks.git/commitdiff
If a line hasn't got a finishing time yet, print an error and exit.
authorNigel McNie <nigel@catalyst.net.nz>
Tue, 3 Jun 2008 23:10:46 +0000 (11:10 +1200)
committerNigel McNie <nigel@catalyst.net.nz>
Tue, 3 Jun 2008 23:10:46 +0000 (11:10 +1200)
Make sure that the line_needs_closing flag is set to 0 correctly at all times when we know we've done the closing time for it.

tks.pl

diff --git a/tks.pl b/tks.pl
index 1979166b6fd01ca216b986f67dc1ef82d37bf392..6ed5c57e7656bbc9f59e2fe16fb644da08eac04c 100755 (executable)
--- a/tks.pl
+++ b/tks.pl
@@ -164,6 +164,17 @@ sub load_timesheet_file {
         }
     }
 
+    foreach my $date ( keys %{$result} ) {
+        my $found_error = 0;
+        if ( my @errors = grep { $_->{needs_closing_time} } @{$result->{$date}} ) {
+            $found_error = 1;
+            foreach my $error ( @errors ) {
+                print "Error on line ", $error->{linenumber}, ": no closing time found\n";
+            }
+        }
+        exit 1 if $found_error;
+    }
+
     return $result;
 }
 
@@ -224,6 +235,7 @@ sub parse_line {
         }
         else {
             $lastline->{time} = (convert_to_minutes($time) - $lastline->{time}) / 60 if $lastline->{needs_closing_time};
+            $lastline->{needs_closing_time} = 0;
 
             # We have a starting date only - need to wait for the next line
             $result->{needs_closing_time} = 1;