# Type: Input # Category: Task # Description: Changes start time of the task # Author: Andriy Lesyuk new Orangutan::Context( response => [ '^(?:Change|set)(?: (?:the|task(?:\'s)?))? start time(?: of(?: the)? task)? to '. '([0-9]{1,2}(?:[:-][0-9]{2})? *(?:(?:a\.?|p\.?)m\.?)?)!*\.*$', '^(?:The )?(?:task(?:\'s)? )?start time(?: of(?: the)? task)? is '. '([0-9]{1,2}(?:[:-][0-9]{2})? *(?:(?:a\.?|p\.?)m\.?)?)!*\.*$', '^(?:Start(?:ed)?|begin|began)(?: (?:my|the|this))?(?: current)?(?: task)? at '. '([0-9]{1,2}(?:[:-][0-9]{2})? *(?:(?:a\.?|p\.?)m\.?)?)!*\.*$', '^(?:Since|from) ([0-9]{1,2}(?:[:-][0-9]{2})? *(?:(?:a\.?|p\.?)m\.?)?)!*\.*$' ], handler => sub { my ($context, $user, $item, $time) = @_; my $task = $user->GetTask; if (!$task) { my $last = $user->GetLast; if ($last) { if ($last->GetEnd->Elapsed <= 3600) { $task = $last; } } } if ($task) { my $date = new Orangutan::Date($time); if ($date) { if ($date->Date == $task->GetStart->Date) { $user->SendMessage([ 'Nothing to change - this is the time you have specified earlier.', 'No need to change - the time is the same.' ]); return; } elsif ($date->Date < $task->GetStart->Date) { if ($main::query->GetEntries($user, $date, $task->GetStart) > 0) { $user->SendMessage([ 'At the time you specified you were working on another task.', "Can't use this time - it conflicts with another task." ]); return; } elsif ($task->GetID && ($date->WorkDayStart->Date != $task->GetEnd->WorkDayStart->Date)) { $user->SendMessage([ "This time is in another work day! Can't change it...", "I won't! It is in previous work day!" ]); return; } } $task->SetStart($date); $main::config->Context('Ok')->Tell($user); if ($task->GetID) { $user->ResubmitLastTask; } } else { $user->SendMessage([ "Can't understand the time you specified... Looks like incorrect!", 'Wrong time! Please specify correct one!', 'Be careful when specifying time!..' ]); } } else { $user->SendMessage([ "Can't change start time of nothing!", 'Start time of what?', 'What start time?' ]); } }, help => { title => 'How can I change the start time of the task?', question => '^(?:How )?(?:(?:can|do) I |to )(?:change) (?:the )?(?:task(?:\'s)? )?'. 'start time(?: of (?:(?:the|a) )?task)?\?*!*\.*$', answer => "Here are the sample requests for changing the start time of the current task:\n". " o Change start time to 10:00\n". " o The start time is 10am\n". " o Begin this task at 16\n". " o Start at 11:00\n". "You can also specify the start time when creating a task:\n". " o Working on the issue since 10:00", weight => 610 }, weight => 90 ); # kate: syntax perl