Program to convert time_t values to user readable format.

This commit is contained in:
hjp 1997-12-17 20:01:20 +00:00
parent 3dcbf25ac5
commit 5d2797efae
2 changed files with 39 additions and 0 deletions

8
time_t/GNUmakefile Normal file
View File

@ -0,0 +1,8 @@
include GNUmakerules
all: time_t
time_t:
clean:
rm time_t
install: $(BINDIR)/time_t

31
time_t/time_t.c Normal file
View File

@ -0,0 +1,31 @@
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
char *cmnd;
void usage(void) {
fprintf(stderr, "Usage: %s time_t ...\n", cmnd);
exit(1);
}
int main(int argc, char **argv) {
int i;
cmnd = argv[0];
if (argc <= 1) usage();
for (i = 1; i < argc; i++) {
time_t t = strtoul(argv[i], NULL, 0);
struct tm *tmp;
char buf[32];
printf("%lu\t", t);
tmp = localtime(&t);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tmp);
printf("%s\n", buf);
}
return 0;
}