src/standard.c
char *date2str_log(char *dst, struct tm *tm, struct timeval *date, size_t size)
{

	if (size < 25) /* the size is fixed: 24 chars + \0 */
		return NULL;

	dst = utoa_pad((unsigned int)tm->tm_mday, dst, 3); // day
	*dst++ = '/';
	memcpy(dst, monthname[tm->tm_mon], 3); // month
	dst += 3;
	*dst++ = '/';
	dst = utoa_pad((unsigned int)tm->tm_year+1900, dst, 5); // year
	*dst++ = ':';
	dst = utoa_pad((unsigned int)tm->tm_hour, dst, 3); // hour
	*dst++ = ':';
	dst = utoa_pad((unsigned int)tm->tm_min, dst, 3); // minutes
	*dst++ = ':';
	dst = utoa_pad((unsigned int)tm->tm_sec, dst, 3); // secondes
	*dst++ = '.';
	utoa_pad((unsigned int)(date->tv_usec/1000), dst, 4); // millisecondes
	dst += 3;  // only the 3 first digits
	*dst = '\0';

	return dst;
}
/* date2str_log: write a date in the format :
 * 	sprintf(str, "%02d/%s/%04d:%02d:%02d:%02d.%03d",
 *		tm.tm_mday, monthname[tm.tm_mon], tm.tm_year+1900,
 *		tm.tm_hour, tm.tm_min, tm.tm_sec, (int)date.tv_usec/1000);
 *
 * without using sprintf. return a pointer to the last char written (\0) or
 * NULL if there isn't enough space.
 */


without using sprintf. return a pointer to the last char written (\0) or
NULL if there isn't enough space.
without using sprintf . return a pointer to the last char written ( \ 0 ) or NULL if there isn ' t enough space .
char *date2str_log(char *dst, struct tm *tm, struct timeval *date, size_t size)
{
	if (size < 25) 
		return NULL;
	dst = utoa_pad((unsigned int)tm->tm_mday, dst, 3); 
	*dst++ = '/';
	memcpy(dst, monthname[tm->tm_mon], 3); 
	dst += 3;
	*dst++ = '/';
	dst = utoa_pad((unsigned int)tm->tm_year+1900, dst, 5); 
	*dst++ = ':';
	dst = utoa_pad((unsigned int)tm->tm_hour, dst, 3); 
	*dst++ = ':';
	dst = utoa_pad((unsigned int)tm->tm_min, dst, 3); 
	*dst++ = ':';
	dst = utoa_pad((unsigned int)tm->tm_sec, dst, 3); 
	*dst++ = '.';
	utoa_pad((unsigned int)(date->tv_usec/1000), dst, 4); 
	dst += 3;  
	*dst = '\0';
	return dst;
}
char * date2str_log ( char * dst , struct tm * tm , struct timeval * date , size_t size ) { if ( size < 25 ) return NULL ; dst = utoa_pad ( ( unsigned int ) tm -> tm_mday , dst , 3 ) ; * dst ++ = ' ' ; memcpy ( dst , monthname [ tm -> tm_mon ] , 3 ) ; dst += 3 ; * dst ++ = ' ' ; dst = utoa_pad ( ( unsigned int ) tm -> tm_year + 1900 , dst , 5 ) ; * dst ++ = ' ' ; dst = utoa_pad ( ( unsigned int ) tm -> tm_hour , dst , 3 ) ; * dst ++ = ' ' ; dst = utoa_pad ( ( unsigned int ) tm -> tm_min , dst , 3 ) ; * dst ++ = ' ' ; dst = utoa_pad ( ( unsigned int ) tm -> tm_sec , dst , 3 ) ; * dst ++ = ' ' ; utoa_pad ( ( unsigned int ) ( date -> tv_usec / 1000 ) , dst , 4 ) ; dst += 3 ; * dst = ' \0 ' ; return dst ; }
date2str_log: write a date in the format :
      sprintf(str, "%02d/%s/%04d:%02d:%02d:%02d.%03d",
              tm.tm_mday, monthname[tm.tm_mon], tm.tm_year+1900,
              tm.tm_hour, tm.tm_min, tm.tm_sec, (int)date.tv_usec/1000);
date2str_log : write a date in the format : sprintf ( str " %02d / %s / %04d : %02d : %02d : %02d . %03d " tm . tm_mday monthname [ tm . tm_mon ] tm . tm_year + 1900 tm . tm_hour tm . tm_min tm . tm_sec ( int ) date . tv_usec / 1000 ) ;
/* the size is fixed: 24 chars + \0 */ // day // month // year // hour // minutes // secondes // millisecondes // only the 3 first digits