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