Files
Arquivotheca.SunOS-4.1.3/lib/libc/gen/common/asctime.c
seta75D 2e8a93c394 Init
2021-10-11 18:20:23 -03:00

56 lines
978 B
C

#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)asctime.c 1.1 92/07/30 SMI";
#endif
/*LINTLIBRARY*/
#include <time.h>
#include <tzfile.h>
static char cbuf[26];
char *ct_numb();
char *
asctime(t)
struct tm *t;
{
register char *cp, *ncp;
register int *tp;
cp = cbuf;
for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;);
ncp = &"SunMonTueWedThuFriSat"[3*t->tm_wday];
cp = cbuf;
*cp++ = *ncp++;
*cp++ = *ncp++;
*cp++ = *ncp++;
cp++;
tp = &t->tm_mon;
ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3];
*cp++ = *ncp++;
*cp++ = *ncp++;
*cp++ = *ncp++;
cp = ct_numb(cp, *--tp);
cp = ct_numb(cp, *--tp+100);
cp = ct_numb(cp, *--tp+100);
cp = ct_numb(cp, *--tp+100);
cp = ct_numb(cp, (t->tm_year + TM_YEAR_BASE)/100);
cp--;
cp = ct_numb(cp, t->tm_year+100);
return(cbuf);
}
static char *
ct_numb(cp, n)
register char *cp;
{
cp++;
if (n>=10)
*cp++ = (n/10)%10 + '0';
else
*cp++ = ' ';
*cp++ = n%10 + '0';
return(cp);
}