summaryrefslogtreecommitdiff
path: root/fdate.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-04 12:32:20 -0500
committerJakob Kaivo <jkk@ung.org>2022-03-04 12:32:20 -0500
commit55f277e77428d7423ae906a8e1f1324d35b07a7d (patch)
tree5c1c04703dff89c46b349025d2d3ec88ea9b3819 /fdate.c
import Miranda 2.066 from upstream
Diffstat (limited to 'fdate.c')
-rw-r--r--fdate.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fdate.c b/fdate.c
new file mode 100644
index 0000000..5a25803
--- /dev/null
+++ b/fdate.c
@@ -0,0 +1,21 @@
+/* reads a filename from stdin and prints its time-last-modified,
+ in format [d]d <Month-name> yyyy */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <time.h>
+
+struct stat buf;
+struct tm *t;
+
+char *month[] = {"January","February","March","April","May","June",
+ "July","August","September","October","November","December"};
+int main()
+{ char f[200];
+ if(scanf("%s",f)==1&&stat(f,&buf)==0)
+ t=localtime(&buf.st_mtime),
+ printf("%d %s %4d\n",(*t).tm_mday,month[(*t).tm_mon],(*t).tm_year+1900);
+ else fprintf(stderr,"fdate: bad file \"%s\"\n",f);
+}