home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
400-499
/
ff473.lzh
/
CNewsSrc
/
cnews_src.lzh
/
libcnews
/
time.c
< prev
Wrap
C/C++ Source or Header
|
1990-05-29
|
910b
|
42 lines
/*
* time utilities
*/
#include <stdio.h>
#ifdef unix
# include <sys/types.h>
# include <sys/timeb.h> /* Amiga's "time" struct is in libc.h */
#endif /* unix */
#include "libc.h"
#include "news.h"
/*
* Write a timestamp of the form "Jun 12 12:34:56.789" on fp.
* N.B.: no trailing newline is written.
*/
void
timestamp(fp, timep)
FILE *fp;
time_t *timep; /* if non-null, return time() here for later use */
{
#ifdef unix
struct timeb ftnow;
char ms[3 + SIZENUL];
ftime(&ftnow);
if (timep != NULL)
*timep = ftnow.time;
/* .15 excludes yyyy\n\0; + 4 omits day-of-week */
(void) fprintf(fp, "%.15s.", ctime(&ftnow.time) + 4);
(void) ltoza(ms, (long)ftnow.millitm, 3); /* 3 digits of output */
(void) fputs(ms, fp);
#else /* !unix */
time_t time_now;
(void) time(&time_now);
(void) fprintf(fp, "%.15s.000", ctime(&time_now) + 4);
if (timep != NULL)
*timep = time_now;
#endif /* unix */
}