aboutsummaryrefslogtreecommitdiff
path: root/src/libventi/time.c
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/time.c
parent7e0b68623394068aec66fe388e0fa446f598c11e (diff)
downloadplan9port-ece9d931eb41e9693c9c3b5e29c6e514bb328713.tar.gz
plan9port-ece9d931eb41e9693c9c3b5e29c6e514bb328713.tar.bz2
plan9port-ece9d931eb41e9693c9c3b5e29c6e514bb328713.zip
libventi: add %+T
Diffstat (limited to 'src/libventi/time.c')
-rw-r--r--src/libventi/time.c9
1 files changed, 6 insertions, 3 deletions
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);