/* @(#)cptime.c	1.4 00/02/13 Copyright 1994 J. Schilling */
#ifndef lint
static	char sccsid[] =
	"@(#)cptime.c	1.4 00/02/13 Copyright 1994 J. Schilling";
#endif
/*
 *	Copyright (c) 1998 J. Schilling
 */
/*@@C@@*/

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>

main(ac, av)
	int	ac;
	char	*av[];
{
	char	**avc;
	int	inc = 0;
	struct stat sb;
	struct timeval *tpp;

	if (ac < 3) {
		error("Usage: ftime file1 file2\n");
		exit(1);
	}
	avc = av;
	if (ac > 1 && streql(av[1], "+")) {
		inc++;
		avc++;
	}
	if (stat(avc[1], &sb) < 0) {
		comerr("Can't stat '%s'\n", avc[1]);
	}
	printf("atime: %s", ctime(&sb.st_atime));
	printf("mtime: %s", ctime(&sb.st_mtime));
	printf("ctime: %s", ctime(&sb.st_ctime));

	if (inc) {
		sb.st_atime += 60;
		sb.st_mtime += 60;
		sb.st_ctime += 60;

		printf("atime: %s", ctime(&sb.st_atime));
		printf("mtime: %s", ctime(&sb.st_mtime));
		printf("ctime: %s", ctime(&sb.st_ctime));
	}
	tpp = &sb.st_atime;
	tpp[0].tv_usec = 0;
	tpp[1].tv_usec = 0;
	tpp[2].tv_usec = 0;
	
	if (utimes(avc[2], tpp) < 0)
		comerr("Can't set times on '%s'\n", avc[2]);
	return (0);
}
