def addtask(self, name, set_to_current=True): """Add a new task with the specified task name Args: name (str): task name set_to_current (Bool): set to current task, default=True """ # create new task task = Task(self.__nextid(), name, util.now_sec()) self.tasks[str(task.id)] = task if set_to_current: self._setcurrent(task) self._echo("added new task #{}".format(task.id)) return task
def pause(self): """Create a pause task and schedule it immediately""" self._update() # create a pause task if len(self.tasks) == 0: task = Task(self.__nextid(), "pause", util.now_sec(), Task.TYPE_PAUSE) self.tasks[str(task.id)] = task # set pause task to active, # it is the task with the first id for key in self.tasks: t = self.tasks[key] if t.type == Task.TYPE_PAUSE: self._setcurrent(t)
def _update(self): if (self.currenttask != None): now = util.now_sec() self.currenttask.update_duration(now)
def adjust_starttime(self, timeinmin): self.duration = self.duration + (int(timeinmin) * 60) self.updated = util.now_sec()
def reset_start(self): self.start = util.now_sec()
def done(self): """Set status of this task to STATUS_DONE """ self.status = Task.STATUS_DONE self.updated = util.now_sec()
def touch(self): """Rest last access time for this task """ self.start = util.now_sec() self.updated = self.start