8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / libc / gen / common / asctime.c
blob92c93325317408ec3aac9609e8ad875f439c2fde
1 /*
2 * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
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 */
12 #pragma ident "%Z%%M% %I% %E% SMI"
14 /*LINTLIBRARY*/
16 #include <time.h>
17 #include <tzfile.h>
19 static char cbuf[26];
21 static char *ct_numb(char *, int);
23 char *
24 asctime(struct tm *t)
26 char *cp, *ncp;
27 int *tp;
29 cp = cbuf;
30 for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;);
31 ncp = &"SunMonTueWedThuFriSat"[3*t->tm_wday];
32 cp = cbuf;
33 *cp++ = *ncp++;
34 *cp++ = *ncp++;
35 *cp++ = *ncp++;
36 cp++;
37 tp = &t->tm_mon;
38 ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3];
39 *cp++ = *ncp++;
40 *cp++ = *ncp++;
41 *cp++ = *ncp++;
42 cp = ct_numb(cp, *--tp);
43 cp = ct_numb(cp, *--tp+100);
44 cp = ct_numb(cp, *--tp+100);
45 cp = ct_numb(cp, *--tp+100);
46 cp = ct_numb(cp, (t->tm_year + TM_YEAR_BASE)/100);
47 cp--;
48 cp = ct_numb(cp, t->tm_year+100);
49 return (cbuf);
52 static char *
53 ct_numb(char *cp, int n)
55 cp++;
56 if (n>=10)
57 *cp++ = (n/10)%10 + '0';
58 else
59 *cp++ = ' ';
60 *cp++ = n%10 + '0';
61 return (cp);