commit d20564a9a6d75192ec21170f2c6cd699eb361d96 from: rsc date: Tue Jul 18 15:23:58 2006 UTC add vttimefmt commit - 2bdefab1da7bc64f433cba5871fc57d5524a06e1 commit + d20564a9a6d75192ec21170f2c6cd699eb361d96 blob - c4538a902897434d9c484ced7e1072720039027f blob + 9fea5bcfd60f67c6f39e2d0e1285f3ce8063da86 --- include/venti.h +++ include/venti.h @@ -487,6 +487,8 @@ int vtfiletruncate(VtFile*); uvlong vtfilegetsize(VtFile*); int vtfilesetsize(VtFile*, u64int); int vtfileremove(VtFile*); + +extern int vttimefmt(Fmt*); extern int chattyventi; extern int ventidoublechecksha1; blob - 2e7d04b3d63943ca894816ffd9dd2481df743da2 blob + 289262ac3283ec0e4fce18840640d66b4bb64a74 --- src/libventi/mkfile +++ src/libventi/mkfile @@ -27,6 +27,7 @@ OFILES=\ srvhello.$O\ strdup.$O\ string.$O\ + time.$O\ version.$O\ zero.$O\ zeroscore.$O\ blob - /dev/null blob + 2d8058f132287a89de5c01ae7b04ff90c05161cf (mode 644) --- /dev/null +++ src/libventi/time.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int +vttimefmt(Fmt *fmt) +{ + vlong ns; + Tm tm; + + if(fmt->flags&FmtLong){ + ns = nsec(); + tm = *localtime(ns/1000000000); + 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); + } +} +