Initial import from FreeBSD RELENG_4:
[dragonfly.git] / crypto / kerberosIV / lib / krb / stime.c
1 /*
2  * $Id: stime.c,v 1.6 1997/05/02 14:29:20 assar Exp $
3  *
4  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
5  * of Technology.
6  *
7  * For copying and distribution information, please see the file
8  * <mit-copyright.h>.
9  */
10
11 #include "krb_locl.h"
12
13 RCSID("$Id: stime.c,v 1.6 1997/05/02 14:29:20 assar Exp $");
14
15 /*
16  * Given a pointer to a long containing the number of seconds
17  * since the beginning of time (midnight 1 Jan 1970 GMT), return
18  * a string containing the local time in the form:
19  *
20  * "25-Jan-1988 10:17:56"
21  */
22
23 const char *
24 krb_stime(time_t *t)
25 {
26     static char st[40];
27     struct tm *tm;
28
29     tm = localtime(t);
30     snprintf(st, sizeof(st),
31              "%2d-%s-%04d %02d:%02d:%02d",tm->tm_mday,
32              month_sname(tm->tm_mon + 1),tm->tm_year + 1900,
33              tm->tm_hour, tm->tm_min, tm->tm_sec);
34     return st;
35 }