mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
add vttimefmt
This commit is contained in:
parent
2bdefab1da
commit
d20564a9a6
3 changed files with 28 additions and 0 deletions
|
@ -488,6 +488,8 @@ uvlong vtfilegetsize(VtFile*);
|
|||
int vtfilesetsize(VtFile*, u64int);
|
||||
int vtfileremove(VtFile*);
|
||||
|
||||
extern int vttimefmt(Fmt*);
|
||||
|
||||
extern int chattyventi;
|
||||
extern int ventidoublechecksha1;
|
||||
extern int ventilogging;
|
||||
|
|
|
@ -27,6 +27,7 @@ OFILES=\
|
|||
srvhello.$O\
|
||||
strdup.$O\
|
||||
string.$O\
|
||||
time.$O\
|
||||
version.$O\
|
||||
zero.$O\
|
||||
zeroscore.$O\
|
||||
|
|
25
src/libventi/time.c
Normal file
25
src/libventi/time.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <venti.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue