Annotation of embedaddon/ntp/libntp/humandate.c, revision 1.1.1.1

1.1       misho       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: 
                     10: extern 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: 
                     15: char *
                     16: humanlogtime(void)
                     17: {
                     18:        char *          bp;
                     19:        time_t          cursec;
                     20:        struct tm *     tm;
                     21:        
                     22:        cursec = time(NULL);
                     23:        tm = localtime(&cursec);
                     24:        if (!tm)
                     25:                return "-- --- --:--:--";
                     26: 
                     27:        LIB_GETBUF(bp);
                     28:        
                     29:        snprintf(bp, LIB_BUFLENGTH, "%2d %s %02d:%02d:%02d",
                     30:                 tm->tm_mday, months[tm->tm_mon],
                     31:                 tm->tm_hour, tm->tm_min, tm->tm_sec);
                     32:                
                     33:        return bp;
                     34: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>