summaryrefslogtreecommitdiff
path: root/libps
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-05-01 00:56:30 +0000
committerMiles Bader <miles@gnu.org>1996-05-01 00:56:30 +0000
commit6ed9c9dc9c3969bd0a75e2bc0a816b37ed167769 (patch)
tree671d765143177cf96f2468565a650faf6d493fb2 /libps
parent15ea7ae7218e4f2f3bcee74db821ec59869cc272 (diff)
(ps_emit_past_time): Implement.
(ps_emit_seconds): Use new args to fmt_seconds. (ps_emit_minutes): Use new args to fmt_minutes.
Diffstat (limited to 'libps')
-rw-r--r--libps/spec.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libps/spec.c b/libps/spec.c
index d4578700..49119f29 100644
--- a/libps/spec.c
+++ b/libps/spec.c
@@ -458,7 +458,7 @@ ps_emit_seconds (struct proc_stat *ps, const struct ps_getter *getter,
G (getter, void)(ps, &tv);
- fmt_seconds (&tv, ABS (width), buf, sizeof (buf));
+ fmt_seconds (&tv, width != 0, width ? -1 : 0, ABS (width), buf, sizeof (buf));
return ps_stream_write_field (stream, buf, width);
}
@@ -472,7 +472,7 @@ ps_emit_minutes (struct proc_stat *ps, const struct ps_getter *getter,
G (getter, int)(ps, &tv);
- fmt_minutes (&tv, ABS (width), buf, sizeof (buf));
+ fmt_minutes (&tv, width != 0, ABS (width), buf, sizeof (buf));
return ps_stream_write_field (stream, buf, width);
}
@@ -481,7 +481,18 @@ error_t
ps_emit_past_time (struct proc_stat *ps, const struct ps_getter *getter,
int width, struct ps_stream *stream)
{
- return 0;
+ static struct timeval now;
+ struct timeval tv;
+ char buf[20];
+
+ G (getter, int)(ps, &tv);
+
+ if (now.tv_sec == 0 && gettimeofday (&now, 0) < 0)
+ return errno;
+
+ fmt_past_time (&tv, &now, ABS (width), buf, sizeof buf);
+
+ return ps_stream_write_field (stream, buf, width);
}
error_t