Listing 1: whattime.c
/* WHATTIME.C
*
* Convert seconds to an epoch date.
*
* Copyright 1994, Lawrence S Reznick
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char **argv)
{
time_t t;
if (argc < 2) {
fputs("Usage:\t", stderr);
fputs(argv[0], stderr);
fputs(" seconds [seconds ...]\n\n", stderr);
fputs("Convert seconds to a calendar time.\n", stderr);
exit(1);
}
while (++argv, --argc) {
t = strtol(*argv, NULL, 0);
fputs(ctime(&t), stdout);
}
return(0);
}
|