17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright 1987 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 77c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 87c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 97c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 107c478bd9Sstevel@tonic-gate */ 117c478bd9Sstevel@tonic-gate 127c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 137c478bd9Sstevel@tonic-gate 147c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/ 157c478bd9Sstevel@tonic-gate 167c478bd9Sstevel@tonic-gate #include <time.h> 177c478bd9Sstevel@tonic-gate #include <tzfile.h> 187c478bd9Sstevel@tonic-gate 197c478bd9Sstevel@tonic-gate static char cbuf[26]; 207c478bd9Sstevel@tonic-gate 21*5d54f3d8Smuffin static char *ct_numb(char *, int); 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate char * 24*5d54f3d8Smuffin asctime(struct tm *t) 257c478bd9Sstevel@tonic-gate { 26*5d54f3d8Smuffin char *cp, *ncp; 27*5d54f3d8Smuffin int *tp; 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate cp = cbuf; 307c478bd9Sstevel@tonic-gate for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;); 317c478bd9Sstevel@tonic-gate ncp = &"SunMonTueWedThuFriSat"[3*t->tm_wday]; 327c478bd9Sstevel@tonic-gate cp = cbuf; 337c478bd9Sstevel@tonic-gate *cp++ = *ncp++; 347c478bd9Sstevel@tonic-gate *cp++ = *ncp++; 357c478bd9Sstevel@tonic-gate *cp++ = *ncp++; 367c478bd9Sstevel@tonic-gate cp++; 377c478bd9Sstevel@tonic-gate tp = &t->tm_mon; 387c478bd9Sstevel@tonic-gate ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3]; 397c478bd9Sstevel@tonic-gate *cp++ = *ncp++; 407c478bd9Sstevel@tonic-gate *cp++ = *ncp++; 417c478bd9Sstevel@tonic-gate *cp++ = *ncp++; 427c478bd9Sstevel@tonic-gate cp = ct_numb(cp, *--tp); 437c478bd9Sstevel@tonic-gate cp = ct_numb(cp, *--tp+100); 447c478bd9Sstevel@tonic-gate cp = ct_numb(cp, *--tp+100); 457c478bd9Sstevel@tonic-gate cp = ct_numb(cp, *--tp+100); 467c478bd9Sstevel@tonic-gate cp = ct_numb(cp, (t->tm_year + TM_YEAR_BASE)/100); 477c478bd9Sstevel@tonic-gate cp--; 487c478bd9Sstevel@tonic-gate cp = ct_numb(cp, t->tm_year+100); 497c478bd9Sstevel@tonic-gate return (cbuf); 507c478bd9Sstevel@tonic-gate } 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate static char * 53*5d54f3d8Smuffin ct_numb(char *cp, int n) 547c478bd9Sstevel@tonic-gate { 557c478bd9Sstevel@tonic-gate cp++; 567c478bd9Sstevel@tonic-gate if (n>=10) 577c478bd9Sstevel@tonic-gate *cp++ = (n/10)%10 + '0'; 587c478bd9Sstevel@tonic-gate else 597c478bd9Sstevel@tonic-gate *cp++ = ' '; 607c478bd9Sstevel@tonic-gate *cp++ = n%10 + '0'; 617c478bd9Sstevel@tonic-gate return (cp); 627c478bd9Sstevel@tonic-gate } 63