<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>sh-tests/omit-time-left.commands</filename>
    </added>
    <added>
      <filename>sh-tests/omit-time-left.expected</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -213,22 +213,6 @@ size_t job_data_size_limit = JOB_DATA_SIZE_LIMIT_DEFAULT;
     &quot;current-waiting: %u\n&quot; \
     &quot;\r\n&quot;
 
-#define JOB_STATS_FMT &quot;---\n&quot; \
-    &quot;id: %&quot; PRIu64 &quot;\n&quot; \
-    &quot;tube: %s\n&quot; \
-    &quot;state: %s\n&quot; \
-    &quot;pri: %u\n&quot; \
-    &quot;age: %&quot; PRIu64 &quot;\n&quot; \
-    &quot;delay: %&quot; PRIu64 &quot;\n&quot; \
-    &quot;ttr: %&quot; PRIu64 &quot;\n&quot; \
-    &quot;time-left: %&quot; PRIu64 &quot;\n&quot; \
-    &quot;reserves: %u\n&quot; \
-    &quot;timeouts: %u\n&quot; \
-    &quot;releases: %u\n&quot; \
-    &quot;buries: %u\n&quot; \
-    &quot;kicks: %u\n&quot; \
-    &quot;\r\n&quot;
-
 /* this number is pretty arbitrary */
 #define BUCKET_BUF_SIZE 1024
 
@@ -982,9 +966,30 @@ static int
 fmt_job_stats(char *buf, size_t size, job j)
 {
     usec t;
+    uint64_t time_left;
 
     t = now_usec();
-    return snprintf(buf, size, JOB_STATS_FMT,
+    if (j-&gt;state == JOB_STATE_RESERVED || j-&gt;state == JOB_STATE_DELAYED) {
+        time_left = (j-&gt;deadline_at - t) / 1000000;
+    } else {
+        time_left = 0;
+    }
+    return snprintf(buf, size,
+            &quot;id: %&quot; PRIu64 &quot;\n&quot;
+            &quot;tube: %s\n&quot;
+            &quot;state: %s\n&quot;
+            &quot;pri: %u\n&quot;
+            &quot;age: %&quot; PRIu64 &quot;\n&quot;
+            &quot;delay: %&quot; PRIu64 &quot;\n&quot;
+            &quot;ttr: %&quot; PRIu64 &quot;\n&quot;
+            &quot;time-left: %&quot; PRIu64 &quot;\n&quot;
+            &quot;reserves: %u\n&quot;
+            &quot;timeouts: %u\n&quot;
+            &quot;releases: %u\n&quot;
+            &quot;buries: %u\n&quot;
+            &quot;kicks: %u\n&quot;
+            &quot;\r\n&quot;,
+
             j-&gt;id,
             j-&gt;tube-&gt;name,
             job_state(j),
@@ -992,7 +997,7 @@ fmt_job_stats(char *buf, size_t size, job j)
             (t - j-&gt;created_at) / 1000000,
             j-&gt;delay / 1000000,
             j-&gt;ttr / 1000000,
-            (j-&gt;deadline_at - t) / 1000000,
+            time_left,
             j-&gt;reserve_ct,
             j-&gt;timeout_ct,
             j-&gt;release_ct,</diff>
      <filename>prot.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6f7117832b6543e2f046b7a3b6088eb2a3c88f2b</id>
    </parent>
  </parents>
  <author>
    <name>Keith Rarick</name>
    <email>kr@xph.us</email>
  </author>
  <url>http://github.com/kr/beanstalkd/commit/5a5f3b7e7598a86c1c57f3153de116111f4acc8d</url>
  <id>5a5f3b7e7598a86c1c57f3153de116111f4acc8d</id>
  <committed-date>2009-10-23T17:00:36-07:00</committed-date>
  <authored-date>2009-10-23T17:00:36-07:00</authored-date>
  <message>Show time-left only when it is meaningful.</message>
  <tree>8b70c2dd907c58e322e63fde1c30275ec06e5991</tree>
  <committer>
    <name>Keith Rarick</name>
    <email>kr@xph.us</email>
  </committer>
</commit>
