source: trunk/athena/bin/discuss/edsc/time.c @ 11192

Revision 11192, 1.2 KB checked in by danw, 27 years ago (diff)
y2k stuff (use tm_year % 100 for 2-digit years)
Line 
1/*
2 *
3 *      Copyright (C) 1989 by the Massachusetts Institute of Technology
4 *      Developed by the MIT Student Information Processing Board (SIPB).
5 *      For copying information, see the file mit-copyright.h in this release.
6 *
7 */
8/*
9 * time-formatting routine to provide shorter output than ctime()
10 * since the extra verbosity isn't necessary
11 */
12
13static char time_buf[15] = "xx/xx/xx xx:xx";
14/* ctime format is "Sun Sep 16 01:03:52 1973\0" */
15/*                  0         1         2   2   */
16/*                  0         0         0   4   */
17/* output format is "mm/dd/yy hh:mm\0"          */
18/*                   0         1                */
19
20#include <stdio.h>
21#include <time.h>
22
23char *
24short_time(time)
25     long *time;
26{
27     register struct tm *now;
28
29     now = localtime(time);
30     time_buf[2] = '/';
31     time_buf[5] = '/';
32     time_buf[8] = ' ';
33     time_buf[11] = ':';
34     time_buf[14] = '\0';
35#define put(n,o) {register int i,j;i=n/10;j=n-10*i;time_buf[o]='0'+i;time_buf[o+1]='0'+j;}
36     now->tm_mon++;
37     put(now->tm_mon, 0);
38     put(now->tm_mday, 3);
39     put(now->tm_year % 100, 6);
40     put(now->tm_hour, 9);
41     put(now->tm_min, 12);
42     return(time_buf);
43}
Note: See TracBrowser for help on using the repository browser.