1/* 2 * humandate - convert an NTP (or the current) time to something readable 3 */ 4#include <stdio.h> 5#include "ntp_fp.h" 6#include "ntp_unixtime.h" /* includes <sys/time.h> and <time.h> */ 7#include "lib_strbuf.h" 8#include "ntp_stdlib.h" 9 10extern const char *months[]; /* prettydate.c */ 11 12/* This is used in msyslog.c; we don't want to clutter up the log with 13 the year and day of the week, etc.; just the minimal date and time. */ 14 15char * 16humanlogtime(void) 17{ 18 char *bp; 19 time_t cursec = time((time_t *) 0); 20 struct tm *tm; 21 22 tm = localtime(&cursec); 23 if (!tm) 24 return "-- --- --:--:--"; 25 26 LIB_GETBUF(bp); 27 28 (void) sprintf(bp, "%2d %s %02d:%02d:%02d", 29 tm->tm_mday, months[tm->tm_mon], 30 tm->tm_hour, tm->tm_min, tm->tm_sec); 31 32 return bp; 33} 34