/*
*/
#include "sm/generic.h"
SM_RCSID("@(#)$Id: timestamp.c,v 1.2 2007/04/25 01:12:08 ca Exp $")
#include "sm/time.h"
#include "sm/io.h"
/*
** SM_TIMESTAMP -- print timestamp
**
** Parameters:
** now -- time to be converted
** fp -- output file
**
** Returns:
** pointer to timestamp.
**
** Locking: must be provided by caller.
*/
sm_ret_T
sm_timestamp(time_t now, sm_file_T *fp)
{
#if MTA_USE_PTHREADS
struct tm tm;
#endif
struct tm *tmp;
#if MTA_USE_PTHREADS
tmp = localtime_r(&now, &tm);
#else
tmp = localtime(&now);
#endif
sm_io_fprintf(fp, "%d-%02d-%02d/%02d:%02d:%02d",
1900 + tmp->tm_year, /* HACK */
tmp->tm_mon + 1,
tmp->tm_mday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
return SM_SUCCESS;
}
syntax highlighted by Code2HTML, v. 0.9.1