2 * humandate - convert an NTP (or the current) time to something readable
6 #include "ntp_unixtime.h" /* includes <sys/time.h> and <time.h> */
7 #include "lib_strbuf.h"
8 #include "ntp_stdlib.h"
10 static const char *months[] = {
11 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
12 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
14 static const char *days[] = {
15 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
26 tm = ntp2unix_tm(ntptime, 1);
29 return "--- --- -- ---- --:--:--";
33 (void) sprintf(bp, "%s, %s %2d %4d %2d:%02d:%02d",
34 days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday,
35 1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
41 /* This is used in msyslog.c; we don't want to clutter up the log with
42 the year and day of the week, etc.; just the minimal date and time. */
48 time_t cursec = time((time_t *) 0);
51 tm = localtime(&cursec);
53 return "-- --- --:--:--";
57 (void) sprintf(bp, "%2d %s %02d:%02d:%02d",
58 tm->tm_mday, months[tm->tm_mon],
59 tm->tm_hour, tm->tm_min, tm->tm_sec);