bot-status.py: Add "Time Since" column to catch outdated state

Rename "Time" column to "Duration", and add "T Since" column for
time since completion of last build.

Change-Id: Ib530151c14798748a292879f515e93e79fe1bd66
diff --git a/monitor/bot-status.py b/monitor/bot-status.py
index e27a7ee..a603c02 100755
--- a/monitor/bot-status.py
+++ b/monitor/bot-status.py
@@ -96,12 +96,14 @@
   reversed_builds = iter(sorted(builds['builds'], key=lambda b: -b["number"]))
   for build in reversed_builds:
     if build['complete']:
-      delta = int(build['complete_at']) - int(build['started_at'])
+      time_since = (int(datetime.now().timestamp()) - int(build['complete_at']))
+      duration = int(build['complete_at']) - int(build['started_at'])
       status = {
         'builderid': build['builderid'],
         'number': build['number'],
         'state': build['state_string'],
-        'time': timedelta(seconds=delta),
+        'time_since': timedelta(seconds=time_since),
+        'duration': timedelta(seconds=duration),
         'fail': build['state_string'] != 'build successful',
       }
       if status['fail']:
@@ -159,8 +161,9 @@
     for builder in server['builders']:
       temp.write("<tr><td colspan=5>&nbsp;</td><tr>\n")
       temp.write("<tr><th colspan=5>{}</td><tr>\n".format(builder['name']))
-      temp.write("<tr><th>Buildbot</th><th>Status</th><th>Time</th>"
-                 "<th>Build #</th><th>Commits</th><th>Failing steps</th></tr>\n")
+      temp.write("<tr><th>Buildbot</th><th>Status</th><th>T Since</th>"
+                 "<th>Duration</th><th>Build #</th><th>Commits</th>"
+                 "<th>Failing steps</th></tr>\n")
       for bot in builder['bots']:
         temp.write("<tr>\n")
         status = bots_status[(base_url, bot['name'])]
@@ -171,8 +174,12 @@
                    .format('red' if status['fail'] else 'green',
                            'FAIL' if status['fail'] else 'PASS'))
         empty_cell="  <td>&nbsp;</td>\n"
-        if 'time' in status:
-          temp.write("  <td>{}</td>\n".format(status['time']))
+        if 'time_since' in status:
+          temp.write("  <td>{}</td>\n".format(status['time_since']))
+        else:
+          temp.write(empty_cell)
+        if 'duration' in status:
+          temp.write("  <td>{}</td>\n".format(status['duration']))
         else:
           temp.write(empty_cell)
         if 'number' in status: