home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
pc.louisiana.edu/pub/unix/
/
Louisiana_UNIX.tar
/
Louisiana_UNIX
/
date+.zoo
/
date+.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-15
|
900b
|
36 lines
/* date+ ... similar to the date(1) program but converts an arbitrary date,
WITH offsets allowed.
USAGE: date+ date_string display_format_string
where date_string has the form mm/dd/yy [hh:mm:ss] [number offset_units [ago]]
and display_format_string is that accepted by strftime().
Adapted from Usenet Bnews' getdate.y by jpd@usl.edu 10 Nov 1991.
*/
#include <stdio.h>
#include <time.h>
static char *rcsid = "@(#)date+ 1.0 10/15/91";
main(argc, argv)
int argc;
char *argv[];
{
struct tm *tmptr;
char buf[128];
time_t tim;
if (argc != 3) {
fprintf(stderr, "Usage: date+ date_str fmt_str\n");
exit (1);
}
tim = getdate(argv[1], NULL);
#ifdef DEBUG
printf("ctime(getdate()) = %s\n", ctime(&tim));
#endif
tmptr = localtime(&tim); /* longint to tm struct */
if (strftime(buf, sizeof(buf), argv[2], tmptr)==0) buf[0] = '\0';
printf("%s\n", buf);
exit(0);
}