1 /* 2 * Copyright 1987 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* 7 * Copyright (c) 1980 Regents of the University of California. 8 * All rights reserved. The Berkeley software License Agreement 9 * specifies the terms and conditions for redistribution. 10 */ 11 12 #pragma ident "%Z%%M% %I% %E% SMI" 13 14 /*LINTLIBRARY*/ 15 16 #include <time.h> 17 #include <tzfile.h> 18 19 static char cbuf[26]; 20 21 char *ct_numb(); 22 23 char * 24 asctime(t) 25 struct tm *t; 26 { 27 register char *cp, *ncp; 28 register int *tp; 29 30 cp = cbuf; 31 for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;); 32 ncp = &"SunMonTueWedThuFriSat"[3*t->tm_wday]; 33 cp = cbuf; 34 *cp++ = *ncp++; 35 *cp++ = *ncp++; 36 *cp++ = *ncp++; 37 cp++; 38 tp = &t->tm_mon; 39 ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3]; 40 *cp++ = *ncp++; 41 *cp++ = *ncp++; 42 *cp++ = *ncp++; 43 cp = ct_numb(cp, *--tp); 44 cp = ct_numb(cp, *--tp+100); 45 cp = ct_numb(cp, *--tp+100); 46 cp = ct_numb(cp, *--tp+100); 47 cp = ct_numb(cp, (t->tm_year + TM_YEAR_BASE)/100); 48 cp--; 49 cp = ct_numb(cp, t->tm_year+100); 50 return(cbuf); 51 } 52 53 static char * 54 ct_numb(cp, n) 55 register char *cp; 56 { 57 cp++; 58 if (n>=10) 59 *cp++ = (n/10)%10 + '0'; 60 else 61 *cp++ = ' '; 62 *cp++ = n%10 + '0'; 63 return(cp); 64 } 65