From 5d2797efaeff08c7c98d5773a1ddfd7be4e766e3 Mon Sep 17 00:00:00 2001 From: hjp Date: Wed, 17 Dec 1997 20:01:20 +0000 Subject: [PATCH] Program to convert time_t values to user readable format. --- time_t/GNUmakefile | 8 ++++++++ time_t/time_t.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 time_t/GNUmakefile create mode 100644 time_t/time_t.c diff --git a/time_t/GNUmakefile b/time_t/GNUmakefile new file mode 100644 index 0000000..f291b00 --- /dev/null +++ b/time_t/GNUmakefile @@ -0,0 +1,8 @@ +include GNUmakerules + +all: time_t + +time_t: +clean: + rm time_t +install: $(BINDIR)/time_t diff --git a/time_t/time_t.c b/time_t/time_t.c new file mode 100644 index 0000000..3f93472 --- /dev/null +++ b/time_t/time_t.c @@ -0,0 +1,31 @@ +#include +#include +#include + +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; +}