aboutsummaryrefslogtreecommitdiff
path: root/src/libventi
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-12-23 12:32:08 -0800
committerRuss Cox <rsc@swtch.com>2008-12-23 12:32:08 -0800
commitece9d931eb41e9693c9c3b5e29c6e514bb328713 (patch)
tree36ac13062b9f3cb75f9177f8dda87e5d488a2933 /src/libventi
parent7e0b68623394068aec66fe388e0fa446f598c11e (diff)
downloadplan9port-ece9d931eb41e9693c9c3b5e29c6e514bb328713.tar.gz
plan9port-ece9d931eb41e9693c9c3b5e29c6e514bb328713.tar.bz2
plan9port-ece9d931eb41e9693c9c3b5e29c6e514bb328713.zip
libventi: add %+T
Diffstat (limited to 'src/libventi')
-rw-r--r--src/libventi/log.c20
-rw-r--r--src/libventi/time.c9
2 files changed, 7 insertions, 22 deletions
diff --git a/src/libventi/log.c b/src/libventi/log.c
index 16535599..47da0328 100644
--- a/src/libventi/log.c
+++ b/src/libventi/log.c
@@ -162,18 +162,6 @@ vtlogremove(char *name)
qunlock(&vl.lk);
}
-static int
-timefmt(Fmt *fmt)
-{
- static uvlong t0;
- uvlong t;
-
- if(t0 == 0)
- t0 = nsec();
- t = nsec()-t0;
- return fmtprint(fmt, "T+%d.%04d", (uint)(t/1000000000), (uint)(t%1000000000)/100000);
-}
-
void
vtlogvprint(VtLog *l, char *fmt, va_list arg)
{
@@ -184,13 +172,7 @@ vtlogvprint(VtLog *l, char *fmt, va_list arg)
if(l == nil)
return;
-
- if(first){
- fmtinstall('T', timefmt);
- first = 0;
- }
-
-
+
qlock(&l->lk);
c = l->w;
n = c->ep - c->wp;
diff --git a/src/libventi/time.c b/src/libventi/time.c
index 2d8058f1..eb686b32 100644
--- a/src/libventi/time.c
+++ b/src/libventi/time.c
@@ -8,15 +8,18 @@ vttimefmt(Fmt *fmt)
vlong ns;
Tm tm;
- if(fmt->flags&FmtLong){
+ if(fmt->flags&FmtSign){
+ ns = va_arg(fmt->args, long);
+ ns *= 1000000000;
+ } else
ns = nsec();
- tm = *localtime(ns/1000000000);
+ tm = *localtime(ns/1000000000);
+ if(fmt->flags&FmtLong){
return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d.%03d",
tm.year+1900, tm.mon+1, tm.mday,
tm.hour, tm.min, tm.sec,
(int)(ns%1000000000)/1000000);
}else{
- tm = *localtime(time(0));
return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d",
tm.year+1900, tm.mon+1, tm.mday,
tm.hour, tm.min, tm.sec);