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
19static	char	cbuf[26];
20
21static char	*ct_numb(char *, int);
22
23char *
24asctime(struct tm *t)
25{
26	char *cp, *ncp;
27	int *tp;
28
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);
50}
51
52static char *
53ct_numb(char *cp, int n)
54{
55	cp++;
56	if (n>=10)
57		*cp++ = (n/10)%10 + '0';
58	else
59		*cp++ = ' ';
60	*cp++ = n%10 + '0';
61	return (cp);
62}
63