2 * prettydate - convert a time stamp to something readable
7 #include "ntp_unixtime.h" /* includes <sys/time.h> */
8 #include "lib_strbuf.h"
9 #include "ntp_stdlib.h"
11 #ifndef TM_IN_SYS_TIME
15 static const char *months[] = {
16 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
17 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
20 static const char *days[] = {
21 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
36 sec = ts->l_ui - JAN_1970;
37 msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */
41 (void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu",
42 (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
43 months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
44 tm->tm_hour,tm->tm_min, tm->tm_sec, msec);
61 sec = ts->l_ui - JAN_1970;
62 msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */
66 (void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu UTC",
67 (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
68 months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
69 tm->tm_hour,tm->tm_min, tm->tm_sec, msec);