Revision 23021,
1.2 KB
checked in by ghudson, 17 years ago
(diff) |
In discuss:
* Fix a crash bug in edsc (int/long mismatch in short_time).
* Put crash dumps in /tmp instead of the antiquated /usr/tmp.
|
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 | |
---|
13 | static 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 | #include <discuss/types.h> |
---|
23 | |
---|
24 | char * |
---|
25 | short_time(time) |
---|
26 | date_times *time; |
---|
27 | { |
---|
28 | register struct tm *now; |
---|
29 | time_t tval = *time; |
---|
30 | |
---|
31 | now = localtime(&tval); |
---|
32 | time_buf[2] = '/'; |
---|
33 | time_buf[5] = '/'; |
---|
34 | time_buf[8] = ' '; |
---|
35 | time_buf[11] = ':'; |
---|
36 | time_buf[14] = '\0'; |
---|
37 | #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;} |
---|
38 | now->tm_mon++; |
---|
39 | put(now->tm_mon, 0); |
---|
40 | put(now->tm_mday, 3); |
---|
41 | put(now->tm_year % 100, 6); |
---|
42 | put(now->tm_hour, 9); |
---|
43 | put(now->tm_min, 12); |
---|
44 | return(time_buf); |
---|
45 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.