+sub late_close_task
+{
+ my $delta = shift;
+ my ($d_sec,$d_min,$d_hour,$d_mday,$d_mon,$d_year,$d_wday,$d_isdst) = localtime();
+
+ return unless is_open;
+
+ my $query = sprintf("UPDATE stempel SET stop=start + interval '%d minutes',time=%d WHERE stop IS NULL",
+ $delta, quarter($delta));
+ $dbh->do($query);
+}
+
+sub move_task
+{
+ my $minutes = shift;
+
+ return unless is_open;
+
+ my $query = sprintf("UPDATE stempel SET start = start - interval '%d minutes' WHERE stop IS NULL", $minutes);
+ $dbh->do($query);
+}
+
+sub alter_task
+{
+ return unless is_open;
+
+ list_open;
+
+ my $term = new Term::ReadLine '';
+
+ my $sql = q{SELECT customer,task FROM stempel WHERE stop IS NULL};
+ my $sth = $dbh->prepare($sql);
+ $sth->execute;
+ my $row = $sth->fetchrow_hashref;
+
+ my $tasks = tasklist $row->{'customer'};
+ $term->addhistory($_) foreach (@$tasks);
+
+ my $attribs = $term->Attribs;
+ $attribs->{completion_word} = $tasks;
+ $term->{completion_function} = sub {return complete_customer $row->{'customer'}, @_};
+
+ my $task = $term->readline ('Aufgabe: ');
+
+ if (length($task) > 0) {
+ my $query = q{UPDATE stempel SET task=? WHERE stop IS NULL};
+ my $sth = $dbh->prepare($query);
+ $sth->execute($task);
+ }
+ exit 0;
+}
+
+sub help
+{
+ print <<"END";
+stempel Copyright (c) 2007,8 Martin Schulze <joey\@infodrom.org>
+ --list [month] list month [default=current|all]
+ --back n move start of current task back by n minutes
+ --open list open
+ --close time close open task
+ --help this text
+ --end|-d terminate task
+ -D terminate task not started today
+ --delete delete open task
+ --reopen re-open last task
+ --task alter task content
+END
+ exit;
+}