Log note :
changed:
-
reactionTime() extension calculates time between the start of the issue and reaction to it from one of the responsible people (i.e. it does not count customers' follow up posts).

I am using "Adding a time log to your issues" from customization docs, if you are not, remove 'timelog'.

In the html folder of your tracker home add the following contents to a file 'issue.item.html'::

    <p tal:condition="python:request.user.hasPermission('Edit', 'timelog') and context.id">
     Reaction time <b><tal:x replace="python:utils.reactionTime(context._klass.history(context._nodeid))" /></b>
    , all time <b><tal:x replace="python:utils.allTime(context.creation.plain(), context.activity.plain())" /></b>
    </p>

In the extensions folder of your tracker home add a file called 'timespent.py' with the following contents::

    import time, datetime, re

    def reactionTime(history):
        i = 0
        while i < len(history):
            if re.search(history[i][2], ('1 3 4 6')):
                return allTime(str(history[0][1]), str(history[i][1]))
            i += 1
        return "none"

    def allTime(time1, time2):
        time_tuple1 = time.strptime(time1, "%Y-%m-%d.%H:%M:%S")
        time_tuple2 = time.strptime(time2, "%Y-%m-%d.%H:%M:%S")
        d1 = datetime.datetime(*time_tuple1[:6])
        d2 = datetime.datetime(*time_tuple2[:6])
        return d2 - d1

    def init(instance):
        instance.registerUtil('reactionTime', reactionTime)
        instance.registerUtil('allTime', allTime)

reactionTime() counts time between issue creation and the first reaction of users 1, 3, 4 or 6. If you want to count reaction time for issues created by users 1, 3, 4 or 6, replace "i = 0" with "i = 1" in reactionTime(). allTime() counts time delta between 2 dates and writes result in format like this: "16 days, 0:17:45".