File:  [Research Unix] / researchv8dc / cmd / cyntax / cem / time.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv8, HEAD
researchv8 Dan Cross

#include	<time.h>
#include	"cem.h"

/*
 *	Return a sstring representation of a time.  If it is
 *	the same year as now leave out the year.  If it is the
 *	same day and we aren't being pedantic leave out the date.
 */
char	*
stime(t)
long	t;
{
	register struct tm	*tp;
	register char		*p;
	static struct tm	this;
	static long		now;
	extern char		*ctime();
	extern long		time();
	extern struct tm	*localtime();

	if (now == 0)
	{
		now = time((long *)0);
		this = *localtime(&now);
	}

	tp = localtime(&t);
	p = ctime(&t);

	if (tp->tm_year == this.tm_year)
		p[19] = '\0';
	else
		p[24] = '\0';

	if
	(
		!pedantic
		&&
		tp->tm_mon == this.tm_mon
		&&
		tp->tm_mday == this.tm_mday
		&&
		tp->tm_year == this.tm_year
	)
		return p + 11;
	else
		return p;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.