taskConfig = $taskConfig; } else { $this->taskConfig = new Config(); } $this->taskwarrior = $this->taskConfig->getTaskwarriorInstance(); $this->logger = $this->taskConfig->getLogger(); } public function importTask(VTodo $ToDoComponent = null){ if(!isset($ToDoComponent)){ $this->logger->error("vCal ToDo component is not defined"); throw new Exception("vCal Todo component is not defined"); } if($this->taskwarrior->exists($ToDoComponent->UID)){ $this->logger->error("Event already exists " . (string)$ToDoComponent->UID); } try { // parse iCalendar event times to DateTime objects //$entry = $this->taskwarrior->parseiCalDateTime($ToDoComponent->DSTAMP); //$start = $this->taskwarrior->parseiCalDateTime($ToDoComponent->DSTART); //$modified = $this->taskwarrior->parseiCalDateTime($ToDoComponent->{'LAST-MODIFIED'}); //$end = $this->taskwarrior->parseiCalDateTime($ToDoComponent->DTEND); $start = $ToDoComponent->DSTART; $entry = $ToDoComponent->DSTAMP; $modified = $ToDoComponent->{'LAST-MODIFIED'}; $end = $ToDoComponent->DTEND; $task = $this->taskwarrior->createTask($ToDoComponent->UID); $tags = $this->taskwarrior->convertToStringArray($ToDoComponent->CATEGORIES); $task->setTags($tags); $task->setDue($ToDoComponent->DUE->getDateTime()); $task->setDescription($ToDoComponent->DESCRIPTION); // override protected taskwarrior properties using iCal event $this->taskwarrior->setValue($task, $this->taskwarrior::ENTRY, $entry); $this->taskwarrior->setValue($task, $this->taskwarrior::START, $start); $this->taskwarrior->setValue($task, $this->taskwarrior::MODIFIED, $modified); $this->taskwarrior->setValue($task, $this->taskwarrior::END, $end); $this->taskwarrior->save($task); } catch(Exception $e){ $this->logger->error($e->message); throw $e; } } } ?>