'started_matches
list of Unicode objects
toggle_matches
list of Unicode objects
now
Unicode object, moment of completion or cancellation of a task
eol
int as str (abs. point of end of task line without line break)
tag
Unicode object (lasted for complete, wasted for cancelled)'

def run(self, edit, started_matches, toggle_matches, now, eol, tag='lasted'):

    if (not started_matches):
        return
    date_format = self.view.settings().get('date_format', '(%y-%m-%d    %H:%M)')
    start = datetime.strptime(started_matches[0], date_format)
    end = datetime.strptime(now, date_format)
    toggle_times = [datetime.strptime(toggle, date_format) for toggle in toggle_matches]
    all_times = (([start] + toggle_times) + [end])
    pairs = zip(all_times[::2], all_times[1::2])
    deltas = [(pair[1] - pair[0]) for pair in pairs]
    delta = format_delta(self.view, sum(deltas, timedelta()))
    tag = ('    @%s(%s)' % (tag, (delta.rstrip(',    ') if delta else ('a    bit' if ('%H' in date_format) else 'less    than    day'))))
    eol = int(eol)
    if (self.view.substr(sublime.Region((eol - 2), eol)) == '        '):
        eol -= 2
    self.view.insert(edit, eol, tag)
