home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / krb / stime.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-15  |  1.0 KB  |  43 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/stime.c,v $
  3.  * $Author: jtkohl $
  4.  *
  5.  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
  6.  * of Technology.
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>.
  10.  */
  11.  
  12. #ifndef lint
  13. static char *rcsid_stime_c =
  14. "$Header: stime.c,v 4.5 88/11/15 16:58:05 jtkohl Exp $";
  15. #endif /* lint */
  16.  
  17. #include <mit-copyright.h>
  18. #include <sys/time.h>
  19. #include <stdio.h>                      /* for sprintf() */
  20.  
  21. /*
  22.  * Given a pointer to a long containing the number of seconds
  23.  * since the beginning of time (midnight 1 Jan 1970 GMT), return
  24.  * a string containing the local time in the form:
  25.  *
  26.  * "25-Jan-88 10:17:56"
  27.  */
  28.  
  29. char *stime(t)
  30.     long *t;
  31. {
  32.     static char st_data[40];
  33.     static char *st = st_data;
  34.     struct tm *tm;
  35.     char *month_sname();
  36.  
  37.     tm = localtime(t);
  38.     (void) sprintf(st,"%2d-%s-%02d %02d:%02d:%02d",tm->tm_mday,
  39.                    month_sname(tm->tm_mon + 1),tm->tm_year,
  40.                    tm->tm_hour, tm->tm_min, tm->tm_sec);
  41.     return st;
  42. }
  43.