date <-> day-number software sought

Peter Honeyman honey at down.FUN
Mon Jul 8 14:23:45 AEST 1985


along similar lines, here's a program (fragment) that converts a date
string to the obvious integer.  the scope of getdate() is unknown to
me, but i use this on ctime format date strings regularly.
	peter

/*
 * emitc -- convert time into an int.  compile with
 * getdate.o, which can be found with netnews source.
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/timeb.h>

main(argc, argv)
char	**argv;
{
	if (argc == 1)
		printf("%ld\n", time((time_t *) 0));
	else {
		char	buf[BUFSIZ], *bptr = buf;

		*bptr = 0;
		while (--argc) {
			strcpy(bptr, *++argv);
			bptr += strlen(bptr);
			*bptr++ = ' ';
		}
		*--bptr = 0;
		printf("%ld\n", getdate(buf, (struct timeb *) 0));
	}
	exit(0);
}



More information about the Comp.sources.unix mailing list